Jump to content
  • Advertisement
Sign in to follow this  
ZHAO Peng

OpenGL Texture mapping problem of shared vertex when drawing elements?

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

Hello, I am working hard at the OpenGL 3.2 core profile and try to write a function like glutSolidSphere. I put the vertex coordinates, normals and texture coordinates in different VBOs and draw all the triangles using glDrawElements. However, there is a problem for texture mapping. In common, sphere surface is cut into several slices using parallel planes. And each slice is approximated using a circular triangle strip. For example, i1_ i2_ i3_ i4 ..... in _ i1 .|\ | \ | \ |..........| \ | j1_\j2_\j3_\j4 ..... jn _\j1 And I allocate the texture coordinates as followed i1....... ...... in i1 (0,vi) ...... (un,vi) (1,vi) j1 ....... jn j1 (0,vj) ...... (un,vj) (1,vi) Among these vertexes, i1 and j1 are used when draw the first and last triangle. For the first triangle, their texture coordinate should be (0,vi) and (0,vj) and for the last one they should be (1,vi) and (1,vj). If I don't want to add two reduplicate vertexes and use the same indices for two triangles, one glDrawElement call could not draw them. Are there some smart ways to deal with this problem? Thank you!

Share this post


Link to post
Share on other sites
Advertisement
Just duplicate the vertices, its the common solution and relatively inexpensive. You're going to have to do this anyway anytime you want to have two textures bordering each other.

Also I might point out that I think triangle strips have fallen out of favor these days, so it might not be worth your trouble to try to make lists instead of just plain triangles. I don't have a great explanation, it has something to do with triangles being more cache friendly, but I don't know for sure.

Share this post


Link to post
Share on other sites
Actually, as you mentioned I just draw plain triangles with duplicate vertexes. Thanks for your quick reply, karwosts.

Share this post


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

  • 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!