OpenGL 旋转问题高手指点
我做了一个直升飞机,想让螺旋桨一直不停旋转。可是生成以后,只有点鼠标才会转,并且旋转后螺旋桨会一直不停的复制自己这里是我的代码希望高手指点#include<gl/glut...
我做了一个直升飞机,想让螺旋桨一直不停旋转。
可是生成以后,只有点鼠标才会转,并且旋转后螺旋桨会一直不停的复制自己
这里是我的代码 希望高手指点
#include <gl/glut.h>
#include <gl/glu.h>
#include <math.h>
#include <stdio.h>
int g_delta_rtri = 0;
void init();
void mydisplay();
GLfloat rtri;
void init()
{
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(0.0,1.0,1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-3.0,3.0,-3.0,3.0,-3.0,3.0);
return TRUE;
}
void mydisplay()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.5,0.25,0.5,0.0,0.0,0.0,0.0,1.,0.0);
glPushMatrix();
glutSolidSphere(0.45, 20, 20);
glPopMatrix();
glPushMatrix();
glTranslatef(0.5,0.0,0.0);
glScalef(4.0,0.3,0.2);
glutSolidCube(0.5);
glPopMatrix();
glRotatef(rtri,0.0f,1.0f,0.0f);
rtri +=.9f;
if (rtri > 360.0f)
rtri -= 360.0f;
asd();
}
asd()
{
glPushMatrix();
glTranslatef(0.0,0.5,0.0);
glScalef(0.2,0.1,5.0);
glutSolidCube(0.5);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0,0.5,0.0);
glScalef(5.0,0.1,0.2);
glutSolidCube(0.5);
glPopMatrix();
}
int main(int argc,char ** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
glutCreateWindow("John");
glutDisplayFunc(mydisplay);
init();
glutMainLoop();
} 展开
可是生成以后,只有点鼠标才会转,并且旋转后螺旋桨会一直不停的复制自己
这里是我的代码 希望高手指点
#include <gl/glut.h>
#include <gl/glu.h>
#include <math.h>
#include <stdio.h>
int g_delta_rtri = 0;
void init();
void mydisplay();
GLfloat rtri;
void init()
{
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(0.0,1.0,1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-3.0,3.0,-3.0,3.0,-3.0,3.0);
return TRUE;
}
void mydisplay()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.5,0.25,0.5,0.0,0.0,0.0,0.0,1.,0.0);
glPushMatrix();
glutSolidSphere(0.45, 20, 20);
glPopMatrix();
glPushMatrix();
glTranslatef(0.5,0.0,0.0);
glScalef(4.0,0.3,0.2);
glutSolidCube(0.5);
glPopMatrix();
glRotatef(rtri,0.0f,1.0f,0.0f);
rtri +=.9f;
if (rtri > 360.0f)
rtri -= 360.0f;
asd();
}
asd()
{
glPushMatrix();
glTranslatef(0.0,0.5,0.0);
glScalef(0.2,0.1,5.0);
glutSolidCube(0.5);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0,0.5,0.0);
glScalef(5.0,0.1,0.2);
glutSolidCube(0.5);
glPopMatrix();
}
int main(int argc,char ** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
glutCreateWindow("John");
glutDisplayFunc(mydisplay);
init();
glutMainLoop();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询