I'm replacing my use of glu methods in my project with glm and I seem to have run into an odd difference that I cannot explain. When I was using this code to set the projection matrix using gluPerspective, I get this displayed:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70.0f, (GLfloat)w / (GLfloat)h, 0.0001f, 1000.0f);
If I switch to glm::perspective, I get this:
glMatrixMode(GL_PROJECTION);
glm::mat4 projectionMatrix = glm::perspective(70.0f, (GLfloat)w / (GLfloat)h, 0.0001f, 1000.0f);
glLoadMatrixf(&projectionMatrix[0][0]);
It's pretty clear that the object I'm rendering is taking up more of the display now with the glm version. There are no other changes in the two versions besides swapping out gluPerspective for glm::perspective.
I'm guessing that I'm probably doing something wrong, because my understanding is that glm::perspective should be a drop in replacement for gluPerspective. But I don't know exactly what that is at this point.
Also, the difference in orientation is because the object is being rotated in the scene. I just ended up taking a screenshot at different times in the animation.
glm nowadays uses radians by default, while gluPerspective()
uses degrees, so you have to use
glm::perspective(glm::radians(70.0f), ...);
to get the same result as gluPerspective(70.0f, ...)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With