Advertisement Jump to content
Sign in to follow this  

OpenGL Updating Vertex Buffers OpenGL ES 2.0

This topic is 1053 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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!