Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

draw(Texture,x,y)

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
add comment

2 Answers 2

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
add comment

Hi i think the following url can give you a solution. blog.terryprobert.co.uk/2012/03/16/android-game-development-quest-pt-3-opengl-drawing-sprites/

share|improve this answer
add comment

Your Answer

 
discard

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.