Search code examples
c++game-engineglm-mathdegreesradians

GLM: function taking degrees as a parameter is deprecated (WHEN USING RADIANS)


Currently using VC++ 11 with SDL2, GLM, and GLEW. The issue is stemming from GLM when I attempt to do two things: Create a rotation matrix, create a perspective camera matrix (3D).

The error is: "GLM: perspective function taking degrees as a parameter is deprecated" despite the fact that I am passing radians (as floats) to both functions. It says I should define something like "#define GLM_FORCE_RADIANS." Is that really necessary?

Personally I use degrees for everything, but OpenGL, so having to convert back and forth (for AI movement and what not) is a pain and actually causes a spike in CPU when I have many NPCs moving.


Solution

  • #define degreesToRadians(x) x*(3.141592f/180.0f)
    

    the static part should be resolved at compile time by the compiler, just surround any degrees to glm stuff with that macro and you are done. Also add

    #define GLM_FORCE_RADIANS
    

    before including and glm headers, so that it will by default use radians instead of degrees