So I've been working on a couple of simple camera classes to try and improve my understanding of the matrix transformations, however my square isn't rendering in view. It's definitely a problem with the matrices, because when I don't do the matrix multiplication in the shader program, it renders as expected in NDC space. This is just orthographic projection by the way.

This is my resize method, which sets the projection matrix (super.resize simply calls glViewport):

1 2 3 4 5 6
| public void resize(int x, int y, int width, int height) { super.resize(x, y, width, height); projection.overwrite(new float[] { 2f / width, 0f, 0f, (x * 2 + width) / width, 0f, 2f / height, 0f, (y * 2 + height) / height, 0f, 0f, 2f, 1f, 0f, 0f, 0f, 1f }); } |

I get the combined projection and view matrices with this method; note that the scale, rotation and translation matrices are all identity matrices by default:

1 2 3 4
| public Matrix4 update() { return projection.copy().multiply(scale).multiply(rotation) .multiply(translation).transpose(); } |

I'm thinking that it might be a problem with my order of multiplication, however I followed the order it states on

this page.

Matrix math is not commutative: S*R is not the same as R*S. However, it is associative: (S*R)*T is the same as S*(R*T). The usual grouping for vertex transformation is this: Final = C*(S*(R*(T*position))). But this can easily be regrouped as: Final = (((C*S)*R)*T)*position.

Here's my vertex shader, nothing special:

1 2 3 4 5 6 7 8
| #version 150
in vec2 position; uniform mat4 mvp;
void main() { gl_Position = mvp * vec4(position, 0.0, 1.0); } |

What am I doing wrong?