Jump to content
  • Advertisement
Sign in to follow this  
Shock

OpenGL OpenGL Geometry Management

This topic is 4815 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 all! Im not having a problem, I just need some advice. In modern game engines how is geometry for the scene managed in terms of sending it to the GPU? Would I be mistaken that vertex buffers are the fastest way to store vertex data on the GPU ( texture uv data too? )? The thing is, I also have learnt too many render calls are not good and if you can, you should batch vertices for drawing. This makes sense. The thing is most geometry would be stored in triangle-strip form. How does one batch triangle-strips for storing in a vertex buffer?? I thought maybe I should store them in a triangle list, but I want the fastest way possible obviously. Also, the scene changes most of the time and I was wondering how you manage vertex buffers because of this. What I mean is, if your scene is constantly changing (e.g walking through a level) your geometry would be changing depending on your update frequency. I thought maybe one could batch triangles (after culling/occlusion tests), have a couple of vertex buffers (dynamic) and transport the scene geometry every update. Is this a bad idea? If so, could you tell me how it's 'really done' ? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Don't modify the geometry every frame. Instead apply the camera's transformation to the modelview matrix and then render the geometry in that frame of reference.

Also, don't modify the geometry just because it moves around. Generally, unless a change effects the shape of an object, you can use matrix transformations. For example, a lift platform can be a static object that is moved up and down by translating the matrix before rendering it.

Often, you can often use vertex weighting, if the hardware supports it, to do shape-shifting transformations for a skinned mesh. This is only going to be particularly effective if you have a boned mesh. If you were using old-fashioned interpolated meshes, you'd need to do something else. I'd adjust the mesh for each frame, but there may be more efficient ways.

Share this post


Link to post
Share on other sites
Quote:
Original post by Shock
Would I be mistaken that vertex buffers are the fastest way to store vertex data on the GPU ( texture uv data too? )?

That's pretty much the case, yeah. Under certain circumstances display lists can be faster, but they're also much more constrained.

Quote:

The thing is most geometry would be stored in triangle-strip form. How does one batch triangle-strips for storing in a vertex buffer?? I thought maybe I should store them in a triangle list, but I want the fastest way possible obviously.

First of all, these days it's not as important to stripify geometry as it used to be. GL_TRIANGLES is fine. Either way, though, you will have one buffer holding all your vertices, and another buffer holding indices. Then you use glDrawElements (or, better, glDrawRangeElements) to actually execute the draws.

Quote:

Also, the scene changes most of the time and I was wondering how you manage vertex buffers because of this. What I mean is, if your scene is constantly changing (e.g walking through a level) your geometry would be changing depending on your update frequency.

You use the transformation matrices, along with things like vertex blending, to avoid changing the values in your vertex buffer.

Quote:
I thought maybe one could batch triangles (after culling/occlusion tests), have a couple of vertex buffers (dynamic) and transport the scene geometry every update. Is this a bad idea? If so, could you tell me how it's 'really done' ?

That's a bad idea. For non-terrain objects, just cull the entire object as one; don't worry about the extra time to draw an entire guy even though only his arm is visible. With correctly set up vertex and index buffers, you won't need to transfer any vertex or index data from the CPU to the GPU per-frame.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Quote:
Original post by Shock
The thing is most geometry would be stored in triangle-strip form. How does one batch triangle-strips for storing in a vertex buffer?? I thought maybe I should store them in a triangle list, but I want the fastest way possible obviously.

First of all, these days it's not as important to stripify geometry as it used to be. GL_TRIANGLES is fine. Either way, though, you will have one buffer holding all your vertices, and another buffer holding indices. Then you use glDrawElements (or, better, glDrawRangeElements) to actually execute the draws.


As an additional to this, with triangle list you want to arrange you indices in strip order and try to keep things in a logical order with in memory so the GPU doesnt have to jump about all over the place to draw and can just stream the data in that much easier

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!