• Advertisement
Sign in to follow this  

GL_TEXTURE_COORDS_ARRAY

This topic is 4937 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, I am trying to texture map a cube using VERTEX ARRAYS. i've a an array of 8 elements (cube vertices) and an index array of 24 ( 4 for each face) but I wonder how do I fit my texture coordinates for all 4 faces (24 elements of x,y) glDrawElements would call on the indices array and vertex array would be accessed by means of traversing through the indices array; but how to texture map it ?? thanks, boyd

Share this post


Link to post
Share on other sites
Advertisement
You could simply store each vertex three times - that way storing the correct texture coordinates would be no problem.

Share this post


Link to post
Share on other sites
A cube is pretty much the worst case for vertex arrays if you need normals and/or texture coordinates. In a corner of the cube, three faces use the same vertex, so the vertices can be shared. However, the shared vertices usually have different normal/texture coordinate, and that makes the three vertices different, so you can no longer share them in the vertex array.

In short, even though there are only 8 vertices in a cube, the fact that (usually) no shared vertices also share other attributs means you must build the cube from 24 unique vertices.

edit: Bah, must learn to type faster [razz]

Share this post


Link to post
Share on other sites
I can think of some specific case where you wouldn't need to store the vertices several times - at least not all of them - but generally I don't think there's a way around this. However, since there are so few vertices involved to begin with, this shouldn't be a problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement