我正在尝试在 C++ 上的 OpenGL 中实现我自己的旋转功能,例如 glRotate。我围绕 y 旋转的代码如下所示:
void do_rotateY(GLdouble angle)
{
//rotate around y axis
GLdouble s = angle;
GLdouble c[4][4];
c[1][1] = c[3][3]= 1.0;
c[0][0] = c[2][2] = cos(s);
c[2][0] = sin(s);
c[0][2] = -c[2][0];
glMultMatrixd(*c);
}
当我打电话时:
glPushMatrix();
do_rotateY(100);
...draw something...
glPopMatrix();
屏幕上什么也没有出现。当我用 glRotatef(...) 替换 do_rotateY(...) 时,我可以正确看到所有内容。