General Structure of an OpenGL ES Application

A standard OpenGL ES application can be divided into three broad stages. This guide will explain each of these stages in detail, looking at how they can be implemented in code. Some of the terms used below may be unfamiliar if you are new to graphics programming, but they will be defined as they are used in the example.


During initialisation, all of the required objects for the application are created and configured. This includes initialising the APIs themselves, the basic elements needed for rendering to screen such as a display and a surface, and the object specific rendering structures such as vertex buffers and shaders.

Drawing the Frame

A frame buffer is a block of memory containing a complete frame of data. A very common technique which is used in many graphical applications to avoid screen flickering is double buffering, which is used in this example application. This is where two frame buffers are used during rendering. All rendering is performed on the back buffer while the display reads separately from the front buffer. When the application has finished rendering a frame, the front and back frame buffers are swapped. The freshly-rendered frame buffer is posted so the display can read from it and rendering begins on the new back buffer.

For an application such as a game, where the visual output needs to be constantly updated, the frame should be redrawn and the buffers swapped in a loop. This can continue for a fixed number of iterations or when the application exits. In the example code in this guide, the application will exit after 800 iterations.

Cleaning Up

Finally, the deinitialisation stage ensures all the resources that had been previously allocated by the application are released. This reduces the chance of any resource leaks occurring when the application exits.