I'm trying to understand projection matrices and I'm messing around with a ortho matrix in OpenGL and it seems like the Y Axis is inverted.
I have a simple square on the screen made using this vertex data:
float size = 32.0f;
float zIndex = -1.0f;
vertices[0] = 0.0f;
vertices[1] = 0.0f;
vertices[2] = zIndex;
vertices[3] = size;
vertices[4] = 0.0f;
vertices[5] = zIndex;
vertices[6] = 0.0f;
vertices[7] = size;
vertices[8] = zIndex;
vertices[9] = size;
vertices[10] = size;
vertices[11] = zIndex;
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 1;
indices[4] = 3;
indices[5] = 2;
I'm using a Right Hand Coord system. X+ goes to the right, Y+ goes up, and Z+ goes towards myself (the direction out of the screen). So I would expect the square to be drawn like this
But when I run and render everything it looks like:
Even when using GLM's ortho matrix it is rendered like this
//GLM ortho setup for 0, 0 center
glm::mat4 projection = glm::orthoRH(-(800.0f / 2.0f), 800.0f / 2.0f, 600.0f / 2.0f, -(600.0f
glm::mat4 mvp = projection;
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &mvp[0][0]);
Also if I use a model matrix and translate it using a positive Y value the red square moves down when I would expect it to move up. I know this is related to the above issue in some way
static float y = 0.0f;
y += 0.1;
glm::mat4 model(1.0f);
model = glm::translate(model, glm::vec3(0.0f, y, 0.0f));
glm::mat4 view(1.0f);
glm::mat4 projection = glm::orthoRH(-(800.0f / 2.0f), 800.0f / 2.0f, 600.0f / 2.0f, -(600.0f / 2.0f), 1.0f, 100.0f);
glm::mat4 mvp = projection * view * model;
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &mvp[0][0]);
Is the Y axis being inverted normal? I must not be understanding something right?