Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

owl

Tutorials on texturing using Vertex Arrays?

This topic is 5426 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

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?

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
this site seems to have some tuts on VA, I will watch them when I come back home.



[edited by - owl on November 17, 2003 10:20:22 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!