Glm :: perspective versus gluPerspective

I am replacing my use of glu methods in my project with glm and it seems I am facing an unusual difference that I cannot explain. When I used this code to set the projection matrix using gluPerspective, I get this:

gluPerspective version

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70.0f, (GLfloat)w / (GLfloat)h, 0.0001f, 1000.0f);

      

If I switch to glm :: perspective, I get this:

glm :: perspective version

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 looking at now takes up more space with the glm version. There are no other changes in the two versions other than the replacement gluPerspective for glm :: perspective.

I am guessing that I am probably doing something wrong because I understand that glm :: perspective should be a replacement for gluPerspective. But I don't know exactly what it is at the moment.

Also, the difference in orientation is that the object rotates in the scene. I just ended up shooting a snapshot at different times in animation.

+3


source to share


1 answer


Glm now uses radians by default and gluPerspective()

uses degrees, so you should use

glm::perspective(glm::radians(70.0f), ...);

      



to get the same result as gluPerspective(70.0f, ...)

.

+5


source







All Articles