Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to basically give myself some sprite drawing functions (making use of openGL) such as;


I want to do this using OpenGL-ES 2.0 on Android. Since the textures can be varying sizes, I was thinking I would save the vertices along with the textures and pass them to the shaders every draw call using "glVertexAttribPointer". Is there a better(performance) way of doing this?

I would also make use of a model matrix to translate/rotate the sprites. Is this a normal thing to do for 2d rendering?

share|improve this question
up vote 4 down vote accepted

You'll want to look at SpriteBatch then which basically involves deferring any actual GPU draw calls until all the drawing has been completed and ready to be flushed to the GPU bugger. This is a very common approach to draw 100s or even 1000s of sprites on a screen at once without negative implications on the frame rate. There's a lot of different ways to implement SpriteBatching so I'll leave the exact implementation in OpenGL to you, but in a lot of implementations I've seen (MonoGame, Direct X Toolkit) the 'Begin' function of the SpriteBatch will take a transform view matrix (which will translate, rotate and scale the sprites). i suggest you look at the implementations I've linked to and derive your own. MonoGame has OpenGL components which will probably be of use to you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.