2.3.3. Viewing transforms

When computing your own viewing matrix, ensure you understand how OpenGL ES handles matrices.

When you multiply the position vector with several matrices to achieve transformations such as translation, rotation, scaling or projection, the effect when applying the resulting matrix on a position vector is as if the individual matrix multiplication operations were performed from right to left. This means that the usual sequence of matrices as defined by OpenGL is, from left to right:

  1. Projection matrix

  2. View matrix

  3. Any number of model transformation matrices, from most global to most local.

You must then multiply the resulting matrix by the vertex position with the matrix on the left.

OpenGL ES assumes matrices are stored in column major order, however arrays in the C programming language are stored in row major order. This means that when you write matrices as constants, they appear transposed. This applies to constants in your application program in addition to shader programs. Figure 2.1 shows an example of a translation matrix.

Figure 2.1. C code and corresponding matrix


Copyright © 2007-2009 ARM. All rights reserved.ARM DUI 0363D
Non-Confidential