Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glm::ortho doesnt display anything

Tags:

c++

glm-math

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.

like image 508
Ams1901 Avatar asked Oct 22 '25 10:10

Ams1901


1 Answers

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.

like image 85
Ams1901 Avatar answered Oct 25 '25 00:10

Ams1901



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!