glDrawElements

Started by
3 comments, last by _the_phantom_ 19 years, 8 months ago
This is kind of a basic question but is glDrawElements the best OpenGL method for drawing an object that might consist of several thousand polygons? I might have been doing it wrong but I found that I had to maintain a very large array that usually held the same point 3 time (because of the different normal information at this point). Some of my objects with a 1000 polygons bloated to several thousand polygons in the rendering stage. I could probably average out the Normals and only store that information for that one single point but from what I remember there were problems with that. I’m rusty so this is kind of a basic question to get me on my way.
Advertisement
Ok I’m sure you are suppose to use glDrawElements...

But what’s confusing me is if I have a vertex with 3 different normals then that means I can’t reuse that vertex, I’ll have to maintain 3 copies of that vertex with there unique normals. I’ve seen vertex arrays get really large because of this and I would like to know if there’s a simpler way of going about this.
no, i'm afriad thats the only way of going about it, each set of data has to be unique per vertex and passed to the gpu like that as groups of data. a bit of extra space required in memory means a much easier and faster gpu design [smile]

btw, you might want to try glDrawRangeElements(), its a tad faster [smile]
Thanks Phantom, wouldn’t think that a larger file would be a better gpu design but its nice to be know that there isn't another solution.
well, the only other way would be to index multiple bits of data at different points, which would increase the complexity of the GPUs design and require more infomation to be pushed over the bus in the long run, where as a normal model wont end up with a huge proproption of the verts duplicated.

It also mucks around with post-T&L cache stuff as you dont get the benifit, plus its adviseable to pack you vertex data into blocks of at least 32bytes in size (which is the min AGP transfer size), which you couldnt do if you were reusing bits of the infomation around the place, instead it would have to fetch from various memory locations and it would stall horribly as things were streamed across.

All in all, belive it or not, duplicating is the best solution currently, maybe that'll change later, who knows [smile]

This topic is closed to new replies.

Advertisement