use*_*068 5 c++ opengl matrix quaternions glm-math
所以我将对象的方向存储在 glm::fquat 中,我想用它来旋转我的模型。我怎么做?
我试过这个:
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glMultMatrixf(glm::mat4_cast(orientation));
glCallList(modelID);
glPopMatrix();
Run Code Online (Sandbox Code Playgroud)
但我收到了这个错误:
error: cannot convert 'glm::detail::tmat4x4<float>' to 'const GLfloat* {aka const float*}' for argument '1' to 'void glMultMatrixf(const GLfloat*)'|
Run Code Online (Sandbox Code Playgroud)
我显然做错了什么,那么正确的方法是什么?
GLM 不会/不能(?)自动将 a 转换为mat4to GLfloat*,因此您必须稍微帮助它。
尝试这个:
#include <glm/gtc/type_ptr.hpp>
glMultMatrixf( glm::value_ptr( glm::mat4_cast(orientation) ) );
Run Code Online (Sandbox Code Playgroud)
这也可能有效:
glMultMatrixf( &glm::mat4_cast(orientation)[0][0] );
Run Code Online (Sandbox Code Playgroud)