2 回答

TA貢獻1895條經(jīng)驗 獲得超3個贊
是立體圖形,只是你采用了平行投影來觀察,且視點設(shè)在與立方體的側(cè)面垂直的位置上,故只能看到一個面。
建議改變視點,或者對立方體先做旋轉(zhuǎn)45度,

TA貢獻1803條經(jīng)驗 獲得超3個贊
幫你修改的代碼
#include <windows.h>
#include <gl/glut.h>
void init(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_FLAT);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glPushMatrix();
glutWireCube(1.0);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void reshape(int w, int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(65.0,(GLfloat)w/(GLfloat)h,1.0,20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0,0.0,-5.0);
}
int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
glutCreateWindow("cube");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
添加回答
舉報