View Full Version : tex coords and gldrawelements
09-01-2005, 03:06 AM
glDrawElements uses the index also to look up the texture coordinates. This is a bit of a pain, since a particular vertex can have different texture coordinates depending on the polygon.
How would you go about solving this?
If you duplicate the vertex, you are starting to eliminate the advantage of using the arrays in the first place.
Duplicating the texture coordinate array (and for example switching the coord pointer between calls with drawarrays) seems like an awful lot of memory waste.
I'm cracking my head trying to find a proper way to solve this, but i guess a lot depends on the models you are using.
Still, anyone has any good ideas?
What you said is true but however the models to be used are decisive.
DrawElements assumes you have a "dense" mesh, one which re-uses many vertices. In real world scenarios, there's no need to do what you want.
Another point is that you have vertices and then you have the attributes.
You mean, since the two vertices have the same xyz coordinates, I want to share, say, texcoords.
Providing this functionality would be difficult and using it would be quite cumbersome. For the time being, you shall duplicate the data.
The fact two vertices does have the same position does not mean they are the same vertex (well, in real world they are, but not here!), consider for example the vertices of a cube. Every face has a different normal so to render correctly they need multiple vertices with the same xyz position.
Mind that: in real world scenarios, the memory waste you refer to is a non-issue.
Sharing vertex data in the way you mean would require some special machinery and heavier difficulties... you would need to have indices for vertex to use, indices for texcoords, indices for normals... what a mess!
09-05-2005, 01:16 AM
Thanks for your input. I guess i will be duplicating the vertices.
However, what you say about having indices for everything... I can see several ways to circumvent that, but i agree it is not the prettiest solution.
Now I am the one who does not understand. ;)
What I meant to say is that you could (theorically) solve the problem by telling the hardware that "vertex 501 uses position i15, texcoords i123 and color i300", using three indices.
What are your ideas on solving the problem? This is somewhat curious to me.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.