View Full Version : GLM::ORTHO reverts Y-axis. Why?

02-24-2018, 12:03 PM
I'm using GLM library. And when I initialize orthographic perspective the Y-axis gets reverted, the positive becomes down. How do I revert it so that the positive is up but still use glm::ortho? Thanks.

glm::mat4 projection_mat = glm::ortho((float)leop_opengl_window.getWidth()*-1.0f, (float)leop_opengl_window.getWidth(), (float)leop_opengl_window.getHeight(), (float)leop_opengl_window.getHeight()*-1.0f);

Dark Photon
02-24-2018, 12:48 PM
Swap your bottom and top arguments.

In OpenGL, the Y axis points up (in eye space and NDC space). So your bottom should be less than your top, unless you intentionally want to flip the orientation vertically.


FAQ#How_to_render_in_pixel_space (https://www.khronos.org/opengl/wiki/FAQ#How_to_render_in_pixel_space)
Flip Y-axis in OpenGL ES? (https://stackoverflow.com/questions/3261739/flip-y-axis-in-opengl-es)