Jump to content
  • Advertisement
Sign in to follow this  
ill

OpenGL Trying to understand OpenGL optimizations like Display Lists, VBO, etc...

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

So when you first learn OpenGL you learn that to draw a triangle or something you do this and it's called immediate mode:

glBegin()

stuf...

glEnd()

Then I learned about how this is inefficient and that there are display lists. I understand display lists perfectly.

Then I heard of Vertex Buffer objects and many other things like that and now I'm having a hard time understanding how they work after all the reading I've done.

Right now I'm trying to explore other options of how to render more efficiently and I've googled all over the place and haven't found anything all that great on my own.

I've looked into Vertex Buffer Objects and I can't really understand what they are fully and when to use them and when not to use them and how to use them efficiently. I bet there are many other things like this somewhere out there I haven't heard of so I'm asking about what the possibilities are.

Right now I'm trying to write a nice efficient renderer for my game world. I wrote a fairly shitty one for my final project in school and it worked great at the time on my hardware. I told my self that for now this will do because it looks nice and that's all that matters, now move on to working on other parts of the project. Now I want to write a better one.

Each triangle face was its own display list. Basically each display list contained a call to glBindTexture(), then glBegin(GL_TRIANGLES), then the 3 vertex commands that specified the normals, texture coords, and the positions. Then a glEnd().

I've read that having a huge amount of display lists is probably not a good idea either since it's just a huge memory hog.

So now I completely rewrote some data structure stuff, and for kicks and debugging and to see if it all works I have an even worse rendering method which showed me just inefficient immediate mode can be. No display lists. Just rendering each face separately in a for loop and calling glBindTexture then glBegin(GL_TRIANGLES) ... glEnd(). It runs fine as long as I don't call glBindTexture before drawing each face, which of course means the level isn't textured properly. This also showed me how important it is to sort the polygons by texture to minimize texture switching.

Share this post


Link to post
Share on other sites
Advertisement
You probably don't want any display lists either, as they are deprecated functionality.

Pretty much everything you want to use vertex buffers for. The advantage to the buffers is that it leaves the vertex data resident on the GPU instead of having to stream it every frame like in immediate mode, and also it saves you from having to make a function call per vertex.

So if you have a 50k vertex mesh that you're drawing every frame, with immediate mode you're calling probably 50,000 OpenGL functions that all need to be sent over the PCI bus.

Compared to a vertex buffer where you store all the vertices on the GPU, and you can fire it off with a single draw call, its orders of magnitude faster. This is somewhat similar to how a display list works too, but they have been deprecated as they aren't really useful when you have vertex buffers available.

Hopefully that helps you some.

Share this post


Link to post
Share on other sites
A few things with your current approach: why are you making a display list per triangle and why are you binding textures per-triangle? Both are hideously inefficient and can be rectified by managing your geometry and texture data properly.

Share this post


Link to post
Share on other sites
Quote:
Original post by JackTheRapper
A few things with your current approach: why are you making a display list per triangle and why are you binding textures per-triangle? Both are hideously inefficient and can be rectified by managing your geometry and texture data properly.


Yeah I know this way sucks and I was doing it this way only for the final project in class because at the time it ran at a nice frame rate on my laptop and I needed to move on to other parts of the project. I demoed it in class and it all worked out.

Now I'm rewriting it completely.

So can VBO's be used for just about everything that Display Lists were usable for?

What kinds of things should go in VBO's? Entire models?

And for level geometry, I need a good way to group triangles up. I obviously can't put the entire level into a display list or VBO (one I figure out VBO's) since I only want parts of the level drawn that are visible. Like Quake for example, would only draw visible polygons.

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!