我正在尝试并排绘制不同颜色的 2 个正方形,我的问题是我无法让 glTranslatef 将我的第二个正方形向右移动,第二个正方形只是在第一个正方形上绘制。
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPointSize(10);
glBegin(GL_QUADS);
glColor3f(0.0,1.0,0.0);
drawSquare();
glTranslatef(10,0,0);
glColor3f(1.0,0.0,0.0);
drawSquare();
glEnd();
glFlush(); // Process all OpenGL routines
}
void drawSquare()
{
glVertex3f(0,0,0);
glVertex3f(10,0,0);
glVertex3f(10,10,0);
glVertex3f(0,10,0);
}