[英]OpenGL : glRotatef not working?
glRoatef功能不起作用我不明白為什么......
下面的代碼這是顯示函數,這也是在使用SDL的主循環中調用的:
void display(){
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);
Control(0.2,0.2,mousein);
drawSkybox(50.0);
UpdateCamera();
renderLine(0,0,0,100,0,0,0,0,255);
renderLine(0,0,0,0,100,0,0,255,0);
renderLine(0,0,0,0,0,100,255,0,0);
我忘了補充說這是不行的:
glPushMatrix();
glRotatef(1,0,0,360);
glScalef(0.05,0.05,0.05);
glCallList(ship);
glPopMatrix();
for(int i = 0;i<planets.size();i++){
glPushMatrix();
planets[i].render();
glPopMatrix();
}
}
在控制功能中,這些旋轉有效。
glRotatef(-camPitch,1.0,0.0,0.0); glRotatef(-camYaw,0.0,1.0,0.0);
更新相機還可以翻譯場景glTranslatef(-camX,-camY,-camZ);
同樣在init功能中,這就是我設置相機的方式
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,640.0/480.0,0.1,500.0);
glMatrixMode(GL_MODELVIEW);
void glRotatef(GLfloat x,GLfloat y,GLfloat z,GLfloat angle)
void glRotatef(GLfloat angle,GLfloat x,GLfloat y,GLfloat z);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.