csdn_dchen 2015-07-03 06:01 采纳率: 0%
浏览 1505

麻烦解释下代码的含义

#include
GLfloat xRotated, yRotated, zRotated;
void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0,0.0,-4.0);
glRotatef(xRotated,1.0,0.0,0.0);
glRotatef(yRotated,0.0,1.0,0.0);
glRotatef(zRotated,0.0,0.0,1.0);
//glScalef(2.0,1.0,1.0);
glutWireCube(1.5);
glFlush(); //Finish rendering
glutSwapBuffers();
}
void Reshape(int x, int y)
{
if (y == 0 || x == 0) return; //Nothing is visible then, so return
//Set a new projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//Angle of view:40 degrees
//Near clipping plane distance: 0.5
//Far clipping plane distance: 20.0
gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);
glMatrixMode(GL_MODELVIEW);
glViewport(0,0,x,y); //Use the whole window for rendering
}
static int times = 0;
void Idle(void)
{
times++;
if(times >30000)
times = 0;
if(times %30000 == 0) { xRotated += 0.3; yRotated += 0.1; zRotated += -0.4; Display(); }
}
int main (int argc, char **argv)
{
//Initialize GLUT
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); //For animations you should use double buffering
glutInitWindowSize(300,300);
//Create a window with rendering context and everything else we need
glutCreateWindow("Cube example");
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
xRotated = yRotated = zRotated = 0.0;
glClearColor(0.5,0.5,0.0,0.0);
//Assign the two used Msg-routines
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutIdleFunc(Idle);
//Let GLUT get the msgs
glutMainLoop();
return 0;
}

  • 写回答

3条回答 默认 最新

  • frank_20080215 2015-07-03 06:24
    关注

    创建一个窗体
    ,然后窗体不停地转动

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名