I have a 2d game I've made using OpenGL ES. The game contains a large quad that fills the entire screen (as a background image) and many smaller quads that make up a number of balls that bounce across the screen.

To illustrate displaying a ball, I may have a single quad with vertices (0,0),(0,1),(1,1),(1,0). I then fill this quad with a texture (a colored ball).

I am wondering if I need to perform back-face culling (for performance reasons). Given these 4 vertices, I assume a polygon is drawn to connect them. Is it actually the case that two polygons are drawn? One facing forward and another one facing the back? I'm struggling to understand.

I have tried getting face culling working and I think I've succeeded, but I've not really noticed any difference in rendering times.

Not sure if relevant, but here is my environment setup code:

gl.glViewport(0, 0, width, height);
gl.glMatrixMode (GL10.GL_PROJECTION);
gl.glOrthof(0, width, height, 0, 0, 1);
gl.glMatrixMode (GL10.GL_MODELVIEW);

Back face culling is typically used to prevent the drawing of polygons to the screen that are facing away from the camera. For example, if one were to draw a complex three dimensional object to the screen, many of the polygons on the model may not even be visible and culling them will prevent the rendering time of these non-visible polygons. The "face" aka visible side of the polygon is determined by the order in which you specify the vertices. Polygons usually only have one face. In a program you might say

glFrontFace( GL_CCW );

This would mean you are going to specify the vertices of your polygons in counter clock wise order, culling the polygons facing away from the camera. Based on the description of your program, it does not sound like you need to enable culling. As long as you are consistent with the ordering of your vertices for your polygons, your two dimensional program should not need culling. As for the question of whether two sides are being drawn, the front and back, no they are not.


If you draw one quad, only one quad is being drawn. You don't need back-face culling for your situation.

Back-face culling is used in 3d graphics as an optimization. For example, if you're drawing a cube, your code would draw 6 quads (one for each side of the cube). However, on screen, there will only be 3 sides ever visible at one time. The other 3 sides will be behind the 3 that you see.

You can use back-face culling to tell OpenGL to only draw the 3 sides that are facing towards the camera. That way you can keep your cube-drawing code simple — always draw 6 quads — but let the system only draw the ones that face the camera. To make this work you have to orient the vertices consistently and tell OpenGL which orientation you're using (see user7679's answer).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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