Topic: implementing a 2D GUI overlay.
When switching to 2D drawing operations, I set up the viewing matrix with “gl.ortho(0, width, 0, height, -1, 1)”. The problem with this is that OpenGL’s coordinate system will have the origin in the bottom left corner of the screen, and have the y-axis increasing upwards. This goes against “traditional” 2D graphics systems, so I’m trying to change it.
First I tried setting up the viewing transform as “gl.ortho(0, width, height, 0, -1, 1)”, but
front-facing polygons are now back-facing and don’t get drawn. Similar tricks with “gl.scaled(1, -1, 1) ; gl.translate(0, -height, 0)” or “gl.translated(width/2, height/2, 0) ; gl.rotated(180, 0, 1, 0) ; gl.rotated(180, 0, 0, 1) ; gl.translated(-width/2, -height/2, 0)” produce the same effect.
Is there any way to change the direction of the y-axis without changing the facing direction of the polygons?
Figuring there was no way to do this, I looked at ways to fix the problems it causes. You can disable/change culling, change the winding direction to GL.CW, draw your polygons the “wrong way round”, or not perform the y-axis switch and just put up with the odd coordinate system OpenGL provides.
What do you think is the “proper” solution to this problem?