Initialising the Application#

The initialisation stage of a simple OpenGL ES application that renders a single triangle is relatively straightforward. You will need to initialise the two APIs that are going to be used:

  • EGL

  • OpenGL ES

EGL is an API used to connect a rendering API, such as OpenGL ES, with a platform’s native windowing system. Before initialisation, the platform-specific wrapper code creates a native window object. This object can then be passed to EGL functions to create objects such as display and surface which are used by OpenGL ES during the rendering process.

The general steps of the initialisation stage are shown below.

Initialise EGL#

  1. Create a display. In most cases this object corresponds to a physical screen. (Creating an EGL Display)

  2. Select an EGL configuration. The choices of configurations available are based on the application’s individual requirements, such as the data sizes of the individual components in the colour buffer or the type of surface needed. (Choosing an EGL Configuration)

  3. Create a surface. This is what the application will render the triangle to. (Creating an EGL Surface)

  4. Create an EGL context. This is used to hold the application’s global state. (Setting up an EGL Context)

Initialise OpenGL ES#

  1. Initialise a vertex buffer to store the vertex data of the triangle. The initial vertex co-ordinates along with the corresponding texture co-ordinates are both inserted into the buffer when it is created. (Creating a Vertex Buffer)

  2. Create a vertex and a fragment shader object. These are both compiled and then bound together in a shader program. This program is then installed as part of the rendering state so its shaders will be used whenever an object is rendered. (Initialising the Shaders)

  3. Create a texture object and set its parameters. For this example, the texture used is a simple checkered pattern which is generated mathematically on-the-fly rather than uploaded. (Creating a Texture)

The following section will guide you through how each of these steps look in practice.

Note

Some of the concepts mentioned above may be unfamiliar but they will be covered in subsequent sections when they are used in the application.