gpt4 book ai didi

c++ - OpenGL : glRotatef not working?

转载 作者:行者123 更新时间:2023-11-30 02:53:47 24 4
gpt4 key购买 nike

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);

Update Camera 也会平移场景 glTranslatef(-camX,-camY,-camZ);

同样在初始化函数中,这就是我设置相机的方式

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);

http://www.opengl.org/sdk/docs/man2/xhtml/glRotate.xml

关于c++ - OpenGL : glRotatef not working?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17628429/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com