Graphics Reference
In-Depth Information
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
;
void ESUTIL_API
esFrustum
(ESMatrix *
result,
GLfloat
left,
GLfloat
right,
GLfloat
bottom,
GLfloat
top,
GLfloat
nearZ,
GLfloat
farZ
)
Multiply matrix specified by
result
with a perspective projection
matrix and return new matrix in
result
.
Parameters:
result
the input matrix
left, right
specify the coordinates for the left and right clipping
planes
bottom, top
specify the coordinates for the bottom and top clipping
planes
nearZ, farZ
specify the distances to the near and far depth clipping
planes; both distances must be positive
Returns:
The new matrix after the perspective projection matrix has been
multiplied is returned in
result