View Full Version : simple 2D scene

10-05-2016, 01:01 PM
Hi! I am new to OpenGl. So far, I have been able to draw polygons on my screen and I have been able to apply textures, use matrix transformations, scaling, texture wrapping etc. I have only worked in 2D.

Now, I want to make a simple animated 2D scene using textured polygons. How do I do this? More specifically, how do I go about defining and using more than one element? Do I definue an array for vertex co-ordinates for every element or just put all the co-ordinates in one array ( sounds like a bad idead) ? I want to do this in an optimized way for which, according to my understanding so far, I should limit the glDraw() calls.

On another note, when using textures, does the glDisableVertexAttribArray() need to be called on the texture co-ordinates too? If yes, then why? Thank you.

10-05-2016, 01:29 PM
I would suggest putting all static images (like backgrounds, etc) in one VBO and all dynamic images (animated sprites, moving objects, etc) in a second VBO. If you have any translucency you should sort the sprites back to front. If they are all completely opaque you dont need to sort. You can use the Z-coordinate and the depth buffer instead. Rendering 2D is pretty fast usually and doesnt need too much optimization unless you actually notice any performance problems.