简体   繁体   中英

glm::ortho doesnt display anything

I need an orthographic projection matrix in OpenGL and I use glm for it like this:

glm::ortho(0.0f, width, 0.0f, height, zNear, zFar);

But this does not produce anything and I can't see anything on the screen. And yes, all of these values are floats.

I suspected it might be the view matrix, but I can render stuff when I use a perspective projection matrix.

Am I passing the wrong arguments? What should I do? Thanks.

As it was mentioned by @Rabbid76 in the comments:

float aspect = (float)width/height;
glm::ortho(-aspect, aspect, -1.0f, 1.0f, zNear, zFar);

Is the solution to my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM