4

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.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
HarrisonG16
  • 853
  • 1
  • 6
  • 15
  • You should specify radians as in glm::radians(45.0f) for example. In any case the warnings are a transitionary measure which will likely disappear in the future. Youre always going to incur some runtime cost when you need to transform your data because a lower level requires it. If degrees -> radians is proving expensive, you'll just have to start converting your code to use radians. You can keep degrees for simplicity when reading in human-readable data files, as well as any editing tools you may have or develop. – qeadz May 30 '14 at 00:32
  • Thank you for your reply. As to what you were saying about specifying radians, that is what I am doing, but for example with the perspective, the FOV angle I'm using is 60 so I did glm::radians(60.0f), but then the function for some reason thinks I'm using degrees and does the radian conversion from 60 (~1 ish) and I get a messed up FOV – HarrisonG16 May 30 '14 at 01:14

2 Answers2

13

Instead of manual transformation you can use

glm::radians(degrees) // from degrees to radians. 

Or

glm::degrees(radians) // from radians to degrees. 

For further information about glm's trigonometry functions consult this page: http://glm.g-truc.net/0.9.4/api/a00136.html#ga4fb76e28851c9ff6653532566084e091

2
#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