Jump to content
  • Advertisement
Sign in to follow this  
Quat

OpenGL Updating Vertex Buffers OpenGL ES 2.0

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

I'm implementing a sprite system to draw sprites.  My first strategy was as follows:

 

1. Use one big dynamic vertex buffer.

2. Sort sprites by render state/texture.

3. For each sprite batch

  a. Fill dynamic vertex buffer with next batch using glBufferSubData.

  b. Issue draw call to draw the batch

 

My thinking was that the driver would discard the old buffer and allocate a new one for the next batch so there would be no stalls.  This is how Direct3D words with the Map/Discard/WriteOnly flags.  Can I expect similar behavior on mobile opengl es 2.0?

 

Later, I was thinking that even if the driver does discard the buffers, it still allocates a lot of buffers per frame (not sure if this is a big deal or not).  So then I was thinking of the following fill strategy:

 

3. For each sprite batch

  a. Fill system memory vertex array with next batch

  b. push_back a struct BatchData = {VertexStart, VertexCount, Texture*, etc.} so I know what region of vertex buffer corresponds to a draw call.

4. Copy all the vertices for all the draw calls to the dynamic vertex buffer using  glBufferSubData

5. For each batch

  a. Draw the BatchData using offset into vertex buffer

 

To me the advantage of the 2nd approach is that I won't discard a whole buffer if the sprite batch was small (like 1-2 sprites), but it requires a 2nd pass.

 

Any thoughts?

 

 

 

 

 

Share this post


Link to post
Share on other sites
Advertisement
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!