Orthographic Matrix Issue

My orthographic matrix doesn’t seem to be properly translating/scaling the pixels on my screen.
Here is how it is built:

	public static Matrix4f orthographicMatrix(float near, float far)
	{
		float width = Display.getWidth();
		float height = Display.getHeight();
		
		return orthographicMatrix(width, height, near, far);
	}
	
	public static Matrix4f orthographicMatrix(float width, float height, float near, float far)
	{
		return orthographicMatrix(0, width, height, 0, near, far); 
	}
	
	public static Matrix4f orthographicMatrix(float left, float right, float bottom, float top, float near, float far)
	{
		Matrix4f mat = new Matrix4f();
		
		mat.m00 = 2 / (right - left);
		mat.m11 = 2 / (top - bottom);
		mat.m22 = -2 / (far - near);
		
		mat.m03 = -1 * ((right + left) / (right - left));
		mat.m13 = -1 * ((top + bottom) / (top - bottom));
		mat.m23 = -1 * ((far + near)   / (far - near));
		
		return mat;
	}

Here’s where I create a new one:

ortho = Matrix4f.orthographicMatrix(1, -1);

Here’s how it’s sent to the vertex shader:

program.setUniformMatrix4("ortho", ortho);

And here’s the vertex shader:

# version 330

uniform mat4 ortho;

in vec3 vert;

void main()
{
	gl_Position = ortho * vec4(vert, 1);
}

When I pass in 2 vectors (0, 0, 0) and (100f, 100f, 0) and draw them as points, this is what I get:

The screen size for that is 800x600. It seems that the x and y directions reversed as intended, but the origin is still in the center. I can’t find what it is that I missed though for that too happen.
The calculated matrix is the same as one that I calculated by hand. So, I feel that I have the wrong expressions to compute the orthographic matrix. Though, I’ve verified from several locations that this is how you calculate it.

It’s hard to say considering you haven’t shown us the setUniformMatrix4() method of your ShaderProgram class? (whatever type program is). My guess is that you tell it to load the transpose of the matrix when you shouldn’t or vice versa.

Ahh. Well, it turns out I’m suppose to use the transpose? I don’t know why. I set it to true, and that fixed the issue. I thought that should have been false, but oh well. Thanks for the suggestion.

That is very odd. Provided you’re using LWJGL Matrix4f.load() (as opposed to loadTranspose() or your own function) it should be set to false. In GLSL if you get the order of the matrix/vector multiplication wrong (ie vector * matrix instead of matrix * vector) then it is the equivalent of multiplying by the transpose of the matrix. (That’s a mathematical thing not just GLSL) But I’m certain that the order you have posted as using here is the right one.

So in conclusion I have no idea.