Jump to content
  • Advertisement
Sign in to follow this  
TFS_Waldo

OpenGL Use glDrawElements?

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

Hey, everyone. I am planning on starting work on a 3D engine sometime, probably today, using SDL + OpenGL. Well, I have a question before I get started. Should I use 'glDrawElements' for things like a 3D model class, etc.? Or should I use VBO's or what? I have used 'glDrawElements' before, but never VBO's. And I'm pretty sure either of these would be better than drawing EACH vertex in a 3D model, etc. ('glVertex3f', etc.) when drawing. So what do you think? I am also wanting to implement heightmapped terrain. So if the terrain is 1024x1024, for example, would it be a good idea to store 64x64 "patches" of the terrain separately, to use frustum culling to draw only visible parts of the terrain? I mean, I could have a class/struct that holds information about each "patch" of terrain, and draw each using 'glDrawElements'. Any suggestions/comments/ideas? Thanks in advance, Matt U.

Share this post


Link to post
Share on other sites
Advertisement
I think what you're asking is whether to use regular vertex arrays or VBOs. glDraw[Range]Elements is used for both. Using VBOs is almost exactly the same as using vertex arrays except you have to bind and possibly update the VBO, and use the pointer parameter to the various gl*Pointer functions as an offset into the VBO instead of a pointer to data. So you can start off using vertex arrays to make sure everything works and then set it up to use VBOs if they're supported without too much hassle afterwards.

Using display lists is another option, but that is purely for static geometry. VBOs will have about the same performance as display lists but have the advantage of being able to update them if you need to.

Any of these methods will almost* always be better then immediate mode (glBegin()/glEnd()).

* There are cases where immediate mode is useful, but for the most part you should ignore it.

EDIT: Whoops, forgot the terrain question. [grin]

Yeah, it's a good idea to not render the entire terrain all the time. There's a lot of research in the area of terrain culling and LOD, most of which can be found at VTerrain.org. If you have any more questions about specific techniques you can ask them in the Graphics Programming and Theory forum.

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!