Sign in to follow this  

Texture coord array problem...

This topic is 4102 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 have a stupid problem for several days now and can't really figure it out...my renderer class is drawing my mesh objects using glDrawElements, the mesh class itself has several buffers for vertex data, face indices, vertex colors, vertex normals, texture coordinates etc...well everything seemed to work fine untill i started work on texturing. My test scene consists of a cube and a grid...well the cube is 8 vertices, 12 faces(triangles), 8 colors, 8 normals and 8 texture coordinates. So far so good but i can't get the texture coordinates right because with the cube there are 3, 4 or 5 triangles sharing the same texture coordinate...the best thing i did is properly texture 5 of the 6 sides of the cube. Maybie i's me not being able to properly set the texture coordinates but after a day trying to do it i'm starting to think that there is something else wrong. After exporting a box mesh in ASCII from 3dsmax i noticed that the cube actualy has 12 texture coordinates and a thing called texture faces. I assume that the texture coordinates are allso indexed and my next question is: Is there a way to draw indexed texture coordinates? glDrawElements accepts only face indices and it doesent seem to use the indices for anything else (like uv coords or vertex colors)

Share this post


Link to post
Share on other sites

Only way to make this working is to duplicate the vertices with multiple texture coordinates.

Since your UV data is given per triangle, you'll notice that every vertex in every triangle can have any UV coordinate. Since there is no way for the GPU to index the texture coordinates, you'll need to create a duplicates.

So, practically, you'll go through all the triangles, check the UV coordinates and try to find a vertex with a same position and UV coordinate. If it cannot be found you'll need to create a new one with the corresponding UV and position.


Yes, it is possible that a vertex can have several texture coordinate sets, but that's another things and don't mess it with this matter.

Cheers and good luck

Share this post


Link to post
Share on other sites

This topic is 4102 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this