标签:
1 #include "stdafx.h" 2 #include <GL/glut.h> 3 #include <stdlib.h> 4 5 void init(void) 6 { 7 glClearColor (0.0, 0.0, 0.0, 0.0); //背景黑色 8 } 9 10 void display(void) 11 { 12 glClear (GL_COLOR_BUFFER_BIT); 13 glColor3f (1.0, 1.0, 1.0); //画笔白色 14 15 glLoadIdentity(); //加载单位矩阵 16 17 gluLookAt(0.0,0.0,5.0, 0.0,0.0,0.0, 0.0,1.0,0.0); 18 glutWireTeapot(2); 19 glutSwapBuffers(); 20 } 21 22 void reshape (int w, int h) 23 { 24 glViewport (0, 0, (GLsizei) w, (GLsizei) h); 25 glMatrixMode (GL_PROJECTION); 26 glLoadIdentity (); 27 gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); 28 glMatrixMode(GL_MODELVIEW); 29 glLoadIdentity(); 30 gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); 31 } 32 33 int main(int argc, char** argv) 34 { 35 glutInit(&argc, argv); 36 glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); 37 glutInitWindowSize (500, 500); 38 glutInitWindowPosition (100, 100); 39 glutCreateWindow (argv[0]); 40 41 init (); 42 glutDisplayFunc(display); 43 glutReshapeFunc(reshape); 44 glutMainLoop(); 45 return 0; 46 }
标签:
原文地址:http://www.cnblogs.com/1024Planet/p/5641283.html