

GlVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vVertices) ĮglSwapBuffers(esContext->eglDisplay, esContext->eglSurface) ĮsCreateWindow(&esContext, "Hello Triangle", 320, 240, GlViewport(0, 0, esContext->width, esContext->height) Draw a triangle using the shader pair created in Init() GlGetProgramInfoLog(programObject, infoLen, NULL, infoLog) ĮsLogMessage("Error linking program:\n%s\n", infoLog) GlGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLen) GlGetProgramiv(programObject, GL_LINK_STATUS, &linked) GlBindAttribLocation(programObject, 0, "vPosition") GlAttachShader(programObject, fragmentShader)


GlAttachShader(programObject, vertexShader) VertexShader = LoadShader(GL_VERTEX_SHADER, vShaderStr) įragmentShader = LoadShader(GL_FRAGMENT_SHADER, fShaderStr) 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 Hello Triangle Example #include "esUtil.h" 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.
