My nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)
Vertex arrays questions
Greetings all
1. If I have a list of polygons to be drawn textured and another list to be drawn *not* textured, is there an efficient way to do that with only one array? I suppose it could be done by loading all of the textured polygons at the beginning of the array and then putting -1.0 in all of the rest, and then turn on enableclientstate for vertex, normal, color, and texture, then use start and end to render the first part, turn off texture and render the second part. Would that really be any better than just having two arrays? I would think that the wasted space would outweigh only having to make one call.
2. Why use glInterleavedArrays? Can''t you just read a sequence of vertex, color, normal, texcoord values into one array and use that offset parameter?
Appreciating any insight!
Joe
Love means nothing to a tennis player
Love means nothing to a tennis player
My nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)
1) You would only waste space if you make the texture array larger than you have to. So if you only need texture coordinates for, say, half the model, just make the texture array half the size of the other arrays. Since you disable it the second time, it won''t be used anyway.
2) You can use the offset, yes. But if there is a predefined interleaved format, you don''t have to.
2) You can use the offset, yes. But if there is a predefined interleaved format, you don''t have to.
Thanks Bob (Hey, *I* have a brother named Bob
)
Regarding #1, I think I may have been referring to interleaved arrays without thinking about it. You mentioned making the texture array smaller, I was referring to using *one* array to render *all* of the polygons, even if some of them weren''t going to be textured. Like this:
VNCTVNCTVNCT (vertex, normal, color, texcoord)
then when I get to the part where the polygons aren''t textured just stick dummy data for T and turn off reading texture coordinates.
Sounds like you answered my question anyway, I think it would be more efficient to have the texcoords in their own array.
Regarding #2, so is there any other benefit besides coding convenience to using glInterleavedArrays?
Love means nothing to a tennis player

Regarding #1, I think I may have been referring to interleaved arrays without thinking about it. You mentioned making the texture array smaller, I was referring to using *one* array to render *all* of the polygons, even if some of them weren''t going to be textured. Like this:
VNCTVNCTVNCT (vertex, normal, color, texcoord)
then when I get to the part where the polygons aren''t textured just stick dummy data for T and turn off reading texture coordinates.
Sounds like you answered my question anyway, I think it would be more efficient to have the texcoords in their own array.
Regarding #2, so is there any other benefit besides coding convenience to using glInterleavedArrays?
Love means nothing to a tennis player
My nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)
Love means nothing to a tennis player
My nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)
1) It, of course, depends on how you get the data (for example, the format of the data you load), but maybe separating the arrays for the two parts would be easier. You could, of course, interleave the arrays for the two parts.
2) Other than wrapping gl*Pointer calls, I find glInterleavedArrays quite useless.
2) Other than wrapping gl*Pointer calls, I find glInterleavedArrays quite useless.
Thanks bob.
One more question if you wouldn''t mind, I did a little bit more reading, and as lovely as all of those texture coordinates are, I didn''t see anything to indicate changing the *bound texture*. What if I have a list of polygons and their texture coordinates but I need to change bound textures?
I suppose that if the vertices were sorted by texture in the array and you knew ahead of time which was which you could make successive calls to glVertexPointer, glColorPointer yada yada yada with the original array plus an appropriate offset, but that''s still making one call to glDrawArrays per texture.
Can you make one call that renders all textures, i.e. that automatically calls glBindTexture???
Thanks again
Joe
Love means nothing to a tennis player
One more question if you wouldn''t mind, I did a little bit more reading, and as lovely as all of those texture coordinates are, I didn''t see anything to indicate changing the *bound texture*. What if I have a list of polygons and their texture coordinates but I need to change bound textures?
I suppose that if the vertices were sorted by texture in the array and you knew ahead of time which was which you could make successive calls to glVertexPointer, glColorPointer yada yada yada with the original array plus an appropriate offset, but that''s still making one call to glDrawArrays per texture.
Can you make one call that renders all textures, i.e. that automatically calls glBindTexture???
Thanks again
Joe
Love means nothing to a tennis player
My nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)
Love means nothing to a tennis player
My nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)
quote:
Original post by Brother Bob
2) Other than wrapping gl*Pointer calls, I find glInterleavedArrays quite useless.
especially with multitexturing.
it''s even more annoying since the interleaved formats are completely backwards of the D3D flexible vertex formats.. which means its a no go if you want api independence. That said D3D FVF is still a lot more limiting than gl*Pointer. but I guess they are more optimized and it''s not really that much of a disadvantage if you design around it...
Ok. that got off topic just a tad...
| - My (new) little website

quote:
Original post by DalTXColtsFan
Thanks bob.
One more question if you wouldn't mind, I did a little bit more reading, and as lovely as all of those texture coordinates are, I didn't see anything to indicate changing the *bound texture*. What if I have a list of polygons and their texture coordinates but I need to change bound textures?
I suppose that if the vertices were sorted by texture in the array and you knew ahead of time which was which you could make successive calls to glVertexPointer, glColorPointer yada yada yada with the original array plus an appropriate offset, but that's still making one call to glDrawArrays per texture.
Can you make one call that renders all textures, i.e. that automatically calls glBindTexture???
Thanks again
Joe
Love means nothing to a tennis playerMy nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)
If you have multiple textures per model(still 1 texture per polygon and not multiple textures per polygon), you should split that model into the number of textures you have. Sort the polygons by texture and render them as if you were rendering many models.
Or better still put all your textures into 1 large texture and render it at one go allowing you to avoid costly texture bind commands.
[edited by - GamerSg on January 22, 2004 10:44:40 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement