作业帮 > 综合 > 作业

Opengl立方体旋转问题

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 18:20:48
Opengl立方体旋转问题
我改变xrot,yrot,zrot值,想让立方体按分别按x=1,y=1,z=1轴旋转
如下代码错误,无论改变xrot,yrot,zrot哪一个,令两个都受影响,不能正确按上述轴旋转
\x05glRotatef(xrot,1.0f,0.0f,0.0f);
\x05glRotatef(yrot,0.0f,01.0f,0.0f);
\x05glRotatef(zrot,0.0f,0.0f,1.0f);
然后我改成
\x05glPushMatrix();
\x05glRotatef(xrot,1.0f,0.0f,0.0f);
\x05glPopMatrix();
\x05glPushMatrix();
\x05glRotatef(yrot,0.0f,01.0f,0.0f);
\x05glPopMatrix();
\x05glPushMatrix();
\x05glRotatef(zrot,0.0f,0.0f,1.0f);
\x05glPopMatrix();
结果无论改变xrot,yrot,zrot哪一个,立方体丝毫不动
无需指正,请直接给出正确的完整(!完整!)代码,请给全(否则追问起来又找不到人了,影响效率,
Opengl立方体旋转问题
xrot+=0.3f;
yrot+=0.2f;
zrot+=0.4f;
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(zrot,0.0f,0.0f,1.0f);
要想得到旋转的效果,必须放在一个计时器里,并且每次都要绘制场景