I have a visualization program using OpenGL and I'm using glRotated for rotation. I have Quaternion data for rotation but I'm not sure how can I apply this to the glRotated function. Do I need to make a conversion first? If so, what should I do?
2 Answers
You need to convert the quaternion to a rotation matrix. See Convert Quaternion rotation to rotation matrix?

- 1
- 1

- 101
- 4
The best way, would be to stop using the deprecated fixed-function pipeline functions.
- glMatrixMode()
- glLoadIdentity()
- glTranslate*()
- glRotate*()
- glBegin()
- etc.
Instead use the new Shader based pipeline, where you simply can call glUniformMatrix4fv()
to provide your own Matrix.
Then you can basically just convert the Quaternions to Matrices.
If you don't want to do all the heavy lifting and calculating all the matrices yourself, then you can use GLM (OpenGL Mathematics).
Also, if you have no idea of how to use the new /modern OpenGL stuff, then you can read these great tutorials.
Alternative
An alternative, that I strongly advice you not to use, since it rely on the deprecated fixed-function pipeline.
Would be to still calculate the Quaternion to a Matrix, and then pass it to OpenGL using glMultMatrix*()

- 23,478
- 6
- 59
- 81