为什么不渲染四边形?我尝试过 glOrtho 和 glFrustrum,输出是一样的:黑屏。据我了解,这段代码表示相机设置在位置 (0,0,-3) 并且它正在查看原点。近平面在 -2 处(距离相机 1 m)。我究竟做错了什么?
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
//glOrtho (-5,5,-5,5,-5,5);
glFrustum(-5,5,-5,5,1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,-3,0,0,0,0,1,0);
glColor3f(1.0,1.0,1.0);
glBegin(GL_QUADS);
glVertex3f(-0.5,-0.5,-0.5);
glVertex3f(0.5,-0.5,-0.5);
glVertex3f(0.5,0.5,-0.5);
glVertex3f(-0.5,0.5,-0.5);
glEnd();
// Don't wait start processing buffered OpenGL routines
glFlush();
glutSwapBuffers();