我需要执行简单的旋转我不会在哪里出错 我希望围绕一个任意点进行轮换。它具有反射和平移,基本上是一个复合变换。
void drawRectangle(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glPushMatrix ();
glRotatef(75.0,1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,100.0,0.0);
glVertex3f(100.0,100.0,0.0);
glVertex3f(100.0,0.0,0.0);
glEnd();
glPopMatrix ();
glFlush();
}
void init_Visualizer(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION); //projection,3D-2D
glLoadIdentity();
glMatrixMode (GL_MODELVIEW);
gluOrtho2D(-640.0,640.0,-480.0,480.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//single buffering(?)
glutInitWindowSize(1200,540);//actual window where to be displayed
glutInitWindowPosition(100,100);
glutCreateWindow("Lab1");
init_Visualizer();
glutIdleFunc(drawRectangle);
glutMainLoop();
}