opengl做立方体旋转
这是我做得一个立方体绕y轴旋转的程序,立方体虽然显示出来了但是没有旋转这是怎么回事,望高手解答一下,十分感谢。#include<GL/glut.h>#include<ma...
这是我做得一个立方体绕y轴旋转的程序,立方体虽然显示出来了但是没有旋转这是怎么回事,望高手解答一下,十分感谢。
#include<GL/glut.h>
#include<math.h>
#include <stdlib.h>
static GLfloat thea=0.0f;
void display()
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-3.0,3.0,-3.0,4.0,1.0,10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(4,4,3,0,0,0,0,0,1);
glutWireCube(1);
glColor3f(1.0,0,0);
glRotatef(thea,0,1,0);
glFlush();
glutSwapBuffers();
}
void myIdle(void)
{
++thea;
if( thea >= 360.0f )
thea = 0.0f;
display();
}
void init()
{
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(0.0,0.0,0.0);
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(200,200);
glutCreateWindow("cube");
init();
glutDisplayFunc(display);
glutIdleFunc(&myIdle);
glutMainLoop();
return 0;
} 展开
#include<GL/glut.h>
#include<math.h>
#include <stdlib.h>
static GLfloat thea=0.0f;
void display()
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-3.0,3.0,-3.0,4.0,1.0,10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(4,4,3,0,0,0,0,0,1);
glutWireCube(1);
glColor3f(1.0,0,0);
glRotatef(thea,0,1,0);
glFlush();
glutSwapBuffers();
}
void myIdle(void)
{
++thea;
if( thea >= 360.0f )
thea = 0.0f;
display();
}
void init()
{
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(0.0,0.0,0.0);
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(200,200);
glutCreateWindow("cube");
init();
glutDisplayFunc(display);
glutIdleFunc(&myIdle);
glutMainLoop();
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询