【OpenGL】OpenGL系列——03堆栈操作

来源:互联网 发布:unix编程 编辑:程序博客网 时间:2024/06/05 15:27


void myinit(void){glClearColor(0.8, 0.8, 0.8, 1.0);//glShadeModel(GL_FLAT); }void display(void){glClear(GL_COLOR_BUFFER_BIT);glColor3f(1.0, 1.0, 0.0);glPushMatrix();glutWireTeapot(1.0);glPopMatrix();glFlush();}void myReshape(GLsizei w, GLsizei h){glViewport(0, 0, w, h);glMatrixMode(GL_PROJECTION);glLoadIdentity();//glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);  //透视矩阵gluPerspective(60.0, (GLfloat)w / (GLfloat)h, 1.0, 20.0);glMatrixMode(GL_MODELVIEW);glTranslatef(0.0, 0.0, -3.0);}int main(int argc, char *argv[]) {glutInit(&argc, argv);glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);glutInitWindowSize(400, 400);glutInitWindowPosition(700, 500);glutCreateWindow("color");myinit();glutReshapeFunc(myReshape);glutDisplayFunc(display);glutMainLoop();return 0;}


0 0