我是opengl的新手。我尝试用自己的矩阵移动球体,但结果不正确。
左侧的球体是我所期望的,我使用 glMultMatrixd() 在右侧生成结果。我做错了什么?
void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glPushMatrix();
GLdouble translate[16] = {1,0,0,1,0,1,0,0,0,0,1,0,0,0,0,1};
glMultMatrixd(translate);
DrawSphere();
glPopMatrix();
glPushMatrix();
glTranslatef(1,0,0);
DrawSphere();
glPopMatrix();
glutSwapBuffers();
}
void Reshape(int width, int height) {
tbReshape(width, height);
glViewport(0, 0, width, height);
glGetIntegerv(GL_VIEWPORT, viewport);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLdouble)width/height, 0.01, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, -5, // eye
0.0, 0.0, 0.0, // center
0.0, 1.0, 0.0); // up
}