

8 Example on how to use GLES2 with SDL2 on the Pandora.5 Combining GLES 1.1 and SDL to make a window on the pandora.UserData *userData = esContext->userData Initialize the shader and program object GlGetShaderInfoLog(shader, infoLen, NULL, infoLog) ĮsLogMessage("Error compiling shader:\n%s\n", infoLog) GlGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen) Ĭhar* infoLog = malloc(sizeof(char) * infoLen)

GlGetShaderiv(shader, GL_COMPILE_STATUS, &compiled) GlShaderSource(shader, 1, &shaderSrc, NULL) GLuint LoadShader(const char *shaderSrc, GLenum type) Create a shader object, load the shader source, and In continue you can see the code of this example. This means there is more setup code required to render than there was in desktop OpenGL using fixed function processing. For those of you not familiar with desktop OpenGL, you will also probably think this is a lot of code just to draw a triangle! Remember though, OpenGL ES 2.0 is fully shader based, which means you can’t draw any geometry without having the appropriate shaders loaded and bound. For those readers familiar with fixed function desktop OpenGL, you will probably think this is a lot of code just to draw a simple triangle. Let’s take a look at the full source code for our Hello Triangle example program, which is listed in Example 2-1. Our purpose here is to get you running your first simple example so that you get an idea of what goes into creating an application with OpenGL ES 2.0. Later in the site, we fill in the details on each of these steps and further document the API. This lesson goes over the basics of each of these steps. Making the contents of the color buffer visible in the EGL windowĪs it turns out, there are quite a significant number of steps required before we can start drawing a triangle with OpenGL ES 2.0.Creating a program object, attaching vertex and fragment shaders, and.Creating an on-screen render surface with EGL.There are number of concepts that we cover in this Lesson: The program we will write is just about the most basic example of an OpenGL ES 2.0 application that draws geometry. In this lesson, we show what is required to create an OpenGL ES 2.0 program that draws a single triangle. To introduce the basic concepts of OpenGL ES 2.0, we begin with a simple example. Lesson 3: Hello Triangle: An OpenGL ES 2.0 Example – Part 1
