Tutorials on texturing using Vertex Arrays?
I''m looking for some, but since I''m not using my computer to connect to the intarweb it''s getting hard to find something good.
Does anybody has some good link to share?
vertex arrays are defined in the openGL red book available here under the Articles & Resources section.
Its really not that hard, you just do this (I assume you already know how to use vertex arrays for vertices):
you enable the arrays
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
bind your texture
glBindTexture(GL_TEXTURE_2D,blah)
tell openGL where the texture coords and vertices are
glTexCoordPointer(2,GL_FLOAT,0(<-whatever your stride is),ptrToArrayOfTexcoords);
glVertexPointer(blah);
then you call whatever drawing method you are using
then you disable the arrays
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
Fairly simple, shouldn't give you too much trouble.
[edited by - GreenToad on November 17, 2003 9:53:50 PM]
you enable the arrays
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
bind your texture
glBindTexture(GL_TEXTURE_2D,blah)
tell openGL where the texture coords and vertices are
glTexCoordPointer(2,GL_FLOAT,0(<-whatever your stride is),ptrToArrayOfTexcoords);
glVertexPointer(blah);
then you call whatever drawing method you are using
then you disable the arrays
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
Fairly simple, shouldn't give you too much trouble.
[edited by - GreenToad on November 17, 2003 9:53:50 PM]
Also watch your attitude in the forums, too. Sarcasm is not appreciated amongst many of the moderators & staff here. Sometimes it takes well over 7 hours for a person to respond
Thanks for replying.
I already know how to use VA, the problem is that I still don''t understand how to define the texture coordinates for the indexed vertices. Maybe it would have been better to ask that question from the beginning, but I thought it may be simple stuff that I could figure out myself with a tutorial.
I already know how to use VA, the problem is that I still don''t understand how to define the texture coordinates for the indexed vertices. Maybe it would have been better to ask that question from the beginning, but I thought it may be simple stuff that I could figure out myself with a tutorial.
As long as you've got a texture coord for each vertex, you shouldn't have to do anything special to use them with an indexed vertex drawing call like glDrawElements().
The indices you give OpenGL when you call glDrawElements() are used for the vertices and for the texture coords, so myVertices[indexarry] uses the texture coordinate data stored at mytexcoords[indexarray].
Hope that clarifies things for you.
[edited by - GreenToad on November 17, 2003 10:05:32 PM]
The indices you give OpenGL when you call glDrawElements() are used for the vertices and for the texture coords, so myVertices[indexarry] uses the texture coordinate data stored at mytexcoords[indexarray].
Hope that clarifies things for you.
[edited by - GreenToad on November 17, 2003 10:05:32 PM]
quote:Original post by Exorcist
Also watch your attitude in the forums, too. Sarcasm is not appreciated amongst many of the moderators & staff here. Sometimes it takes well over 7 hours for a person to respond
My apologise to all the members who felt my attitude was inappropiate. My english can sound harsh sometimes. This time wasn''t intentional.
quote:Original post by GreenToad
As long as you''ve got a texture coord for each vertex, you shouldn''t have to do anything special to use them with an indexed vertex drawing call like glDrawElements(). The same indices for the vertices are used for the texture coords when you call something like glDrawElements(), so myVertices[indexarry] uses the data stored at mytexcoords[indexarray].
That makes sense. So if I pseudo-define:
vertices {-1.0,-1.0, 1.0, 1.0,-1.0, 1.0, 1.0, 1.0, 1.0,-1.0, 1.0, 1.0,-1.0,-1.0, -1.0, 1.0,-1.0, -1.0, 1.0, 1.0, -1.0,-1.0, 1.0, -1.0,}
For a cube, the texture coordinates for all 6 faces would be...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement