1
\$\begingroup\$

I am writing a small 2D SHMUP for Android at the moment. Pure 2D rendering with Bitmaps turned out to be a bit too slow, especially with a lot of alpha blending going on. So I decided to switch my rendering backend to OpenGL. Last time I used OpenGL there was still immediate mode. I now want to build a modern architecture with OpenGL ES 2.0.

Here are the details: Most of the time I am going to display a lot of Sprites, that are essentially texure mapped quads consisting of 2 triangles each. I am probably going to want to render a lot of them :) I am going to use Vertex Buffers because of the faulty VBO implementation in Froyo.

Here's the question: How would I manage the position data of the independent sprites? Do I need to modify my vertex buffers each time a sprite changes its position? Or is it faster to use a single draw call and translation matrix for each sprite?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

For a large number of sprites, each of which is just a quad, I'd lean toward using dynamic vertex buffers and drawing them all in one draw call. The sprite bitmaps will all need to be in one atlased texture for this, since you can't switch textures in the middle of a vertex buffer.

Disclaimer, though: my experience is based on PC and console hardware and I'm unfamiliar with the performance tradeoffs on mobile hardware, which might be different.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks Nathan. That means, that if the positions of the sprites change, I edit the buffer in the places with the vertex information (hence dynamic) and use the buffer on the next draw cycle? \$\endgroup\$
    – thalador
    Jul 12, 2012 at 21:37
  • \$\begingroup\$ Something like that. I'm not sure just what the setup is to do dynamic vertex buffers efficiently in OpenGL. In D3D you'd map the buffer with the MAP_WRITE_DISCARD flag to regenerate it each frame. That probably doesn't help you much though. :) \$\endgroup\$ Jul 12, 2012 at 21:56
  • 1
    \$\begingroup\$ In OpenGL glBufferData and glBufferSubData will create and update the vertex buffer contents. glBufferData() with GL_DYNAMIC_DRAW will indicate that the buffer is used for rendering and will change frequently. \$\endgroup\$
    – Aaron
    Jul 13, 2012 at 2:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .