Search code examples
openglcoordinateslwjglslick2d

OpenGL won't render with top left coordinates


I got my projection matrix setup with glOrtho() like this:

glOrtho(-Application.HALF_WIDTH, Application.HALF_WIDTH, -Application.HALF_HEIGHT, Application.HALF_HEIGHT, 1, -1);

So, when I draw something at origin (0; 0), opengl draws it at the center of the screen. Fine. But now I want to flip the Y coordinate, so I've changed it to this:

glOrtho(-Application.HALF_WIDTH, Application.HALF_WIDTH, Application.HALF_HEIGHT, -Application.HALF_HEIGHT, 1, -1);

And when I try to draw at (0; 0) (or at any position), it gives a black screen.

What could cause this problem? p.s. i'm using lwjgl


Solution

  • When changing the orientation of the y-axis, also the winding order of the primitives changes. So if backface culling is enabled, one has to adjust the winding order by setting it with

    glFontFace(GL_CCW)