OpenGL glRotatef与glCallList怎样配合?
各位大神,帮我看看这个程序,我想让卫星绕自己的体轴转动,但是卫星总是绕着一个未知轴转动,求指导!绘制函数程序如下,定时器执行,让卫星绕y轴自转:程序代码:
void CVirtualrotaterView::RenderScene() { counter++; static GLfloat sunpos[4] = {0.7, 0, 10.0, 0.0}; static GLfloat suncolor[4] = {0.5, 0.5, 0.5, 1.0}; static GLfloat sunambient[4] = {0.5, 0.5, 0.4, 1.0}; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glColor3f(1, 1, 1); //设置光照 glEnable(GL_LIGHTING); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, sunambient); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, sunpos); glLightfv(GL_LIGHT0, GL_DIFFUSE, suncolor); glLightfv(GL_LIGHT0, GL_AMBIENT, sunambient); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ////////////////////////////////视角////////////////////////////// //gluLookAt(800.0,0.0,0,0.0,0.0,0.0,0.0f,1.0f,0.0f); Camera();//视点处理,即看的角度 glPushMatrix(); //glTranslatef(-1500+distance[1], 0.0, -1200.0);//横向位移,在此读取数据 //glTranslatef(-1000, 0.0, -1200.0);//载入后位置 glTranslatef(0.0, -200, 0.0); /***************初始姿态调整,一般无需修改*************/ //glRotatef(90, 0.0, 0.0, 1.0); glRotatef(Eulerangle2, 0.0, 1.0, 0.0); if(change_flag==1) { glCallList(list_id[1]); } else { glCallList(list_id[0]); } glPopMatrix(); DrawSky(); DrawEarth(); DrawSun(); } }