ES Framework API - OpenGL ES 3.0: Programming Guide, Second Edition (2014)

OpenGL ES 3.0: Programming Guide, Second Edition (2014)

Appendix C. ES Framework API

The example programs throughout the book use a framework of utility functions for performing common OpenGL ES 3.0 functions. These utility functions are not part of OpenGL ES 3.0, but rather are custom functions that we wrote to support the sample code in the book. The ES Framework API is included with the source code for the book available from the book website at opengles-book.com. The ES Framework API provides routines for tasks such as creating a window, setting up callback functions, loading a shader, loading a program, and creating geometry. The purpose of this appendix is to provide documentation for the ES Framework API functions used throughout the book.

Framework Core Functions

This section provides documentation on the core functions in the ES Framework API.

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Transformation Functions

We now describe utility functions that perform commonly used transformations such as scale, rotate, translate, and matrix multiplication. Most vertex shaders will use one or more matrices to transform the vertex position from local coordinate space to clip coordinate space (refer to Chapter 7, “Primitive Assembly and Rasterization,” for a description of the various coordinate systems). Matrices are also used to transform other vertex attributes such as normals and texture coordinates. The transformed matrices can then be used as values for appropriate matrix uniforms used in a vertex or fragment shader. You will notice similarities between these functions and appropriate functions defined in OpenGL and OpenGL ES 1.x. For example, esScale should be quite similar to glScale, esFrustum should be similar to glFrustum, and so on.

A new type, ESMatrix, is defined in the framework. This is used to represent a 4 × 4 floating-point matrix and is declared as follows:

typdedef struct {
GLfloat m[4][4];
}ESMatrix;

Image

Image

Image

Image

Image

Image

Image

Image

Image