JOML orthographic projection failure.

I just moved my 2D project over from using a matrix/vector maths library I wrote to JOML and everything is good except my camera’s projection matrix is screwed when I use JOML’s matrix.ortho() method. In my test scene I just have a single tilemap about 40*30 tiles in size and a controllable “camera”. With my own implementation of an orthographic projection matrix everything is great, but with JOML’s nothing is rendered.

Everything else works just fine with JOML, it is only the ortho projection that doesn’t.

Below is the offending code:


matrix.ortho(0, width, 0, height, near, far).get(buffer);
glUniformMatrix4fv(location, false, buffer);

Is there something specific to JOML that I’m missing here? Thanks for your time.

Yes. You should read the JavaDocs of that method. You are probably missing the fact that every method in Matrix4f (except when mentioned otherwise) postmultiplies its respective transformation to the current matrix, just like all OpenGL matrix stack and GLU functions do.
What you probably wanted to call was setOrtho(). But all of this is mentioned in the JavaDocs of each method.

Thankyou. I had already looked at the docs for ortho() but for some reason it had not clicked in my mind that it post-multiplied. Maybe because I’m so used to using a different library. Either way, thanks you for your time and sorry to have bothered you with a question I really should have been able to answer myself.