I was having this problem with OpenGL where I'd have all my textures being rendered upside down. I did the most logical thing I could think of and tried reversing the order of the mapping and that fixed the issue. But why? I know that OpenGL's coordinate system is cartesian and that it works by mapping each uv to a specific vertex. I had something like [0,0], [0,1], [1,1], [1,0] which would theoretically as far as I understand it go from:
top-left -> bottom-left -> bottom-right -> top-right.
I changed this to: [1,1], [1,0], [0,0], [0,1] which would represent:
bottom-right -> top-right -> top-left -> bottom left.
In my understanding it should be quite the opposite. Making a pretty quick sketch on paper it shows me that the initial order would theoretically render my texture correctly and not upside down. Am I correct and theres something else messing with my rendering? Like my perspective matrix?
This is my orthographic matrix:
Matrix4f ortho = new Matrix4f();
ortho.setIdentity();
float zNear = 0.01f;
float zFar = 100f;
ortho.m00 = 2 / (float) RenderManager.getWindowWidth();
ortho.m11 = 2 / -(float) RenderManager.getWindowHeight();
ortho.m22 = -2 / (zFar - zNear);
return ortho;
I can't really say I understand it though, I had quite a hard time with it. And looking through youtube tutorials and articles you can see most people don't really understand it either, they just use it. I do have a good linear algebra background but still can't wrap my head around how is this matrix normalizing my coordinates (screen coords to OpenGL coords (-1,1)). Anyway, I digress, any help is appreciated.