Friday 26 July 2013

OpenGL ES: Is modelview matrix column major or row major?

Modelview matrix is column major. In memory, it is like

M00, M10, M20, M30, M01, M11, M21, M31, M02, M12, M22, M32, M03, M13, M23, M33

A translation of (x, y, z) is

1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1

In GLSL, matrix vector multiplication is defined as matrix * vector.

In host program, depending on how you define your matrix vector multiplication operator, it can be either matrix * vector or vector * matrix.

For a series of transformations M1, M2, M3,

if you define matrix-vector multiplication as matrix * vector,  the total transformation is

M3 * M2 * M1

If you define it as vector * matrix, the total transformation is

M1 * M2 * M3

No comments:

Post a Comment