The 11 steps to render in OpenGL ES

The OpenGL API is vast. It has so many function calls that remembering them is an uphill battle. OpenGL is also a state machine. There are so many steps that you need to remember. Rendering in OpenGL is quite simple, but, the steps to do so may be forgotten after a couple of days. It happens to me. I tend to work on my 3D game engine daily and I still forget these steps. I decided to set up a post so I can remember how to render in OpenGL ES.

Here are the 11 steps required to render an object in OpenGL ES. I hope they are helpful to you. Try to use these steps as a cheat-sheet.

Let's start:

Assume characterData contains the data of your character which you want to render:

//Vertex data of character
float characterData[36]={1.0,0.4,0.9,1.0,....};

Step 1. Generate a Vertex Array Object:

//1. Generate a Vertex Array Object. Assume you have a global GLuint myVertexArrayObject declared.

Step 2. Bind the Vertex Array Object:

//2. Bind the Vertex Array Object

Step 3. Generate a Vertex Buffer Object:

//3. Create a vertex buffer object
GLuint myBuffer;


Step 4. Bind the Vertex Buffer Object:

//4. Bind the vertex buffer

Step 5. Load Data into the buffer:

//5. Load data in the buffer

Step 6. Get Location of Attributes in current active shader:

//6. Get the location of the shader attribute called "position". Assume positionLocation is a global GLuint variable

positionLocation=glGetAttribLocation(programObject, "position");

Step 7. Get Location of Uniform in current active shader:

//7. Get Location of uniform called "modelViewProjectionMatrix". Assume modelViewProjectionUniformLocation is a global GLuint variable.

modelViewProjectionUniformLocation = glGetUniformLocation(programObject,"modelViewProjectionMatrix");

Step 8. Enable the attribute location found in the shader:

//8. Enable the attribute location

Step 9. Link buffer data to shader attributes:

//9. Link the buffer data to the shader attribute locations and inform OpenGL about the types of data in bound buffers and any memory offsets needed to access the data

glVertexAttribPointer(positionLocation,3, GL_FLOAT, GL_FALSE, 0, (const GLvoid *)0);

Step 10. Draw using data in currently bound and enabled buffers:

//1. Bind the VAO

//2. Start the rendering process
glDrawArrays(GL_TRIANGLES, 0, 36);

//3. Unbind the VAO

Step 11. Delete previously generated buffer:

glDeleteBuffers(1, &myBuffer);

PS. Sign up to my newsletter and get OpenGL development tips.

Harold Serrano

Computer Graphics Enthusiast. Currently developing a 3D Game Engine.