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?


1 Answer 1


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.


You must log in to answer this question.

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