|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
#include <gl\glut.h> #include <gl\GLU.h> #include <gl\GL.h> void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // glRotatef(30, 1, 1, 1); glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 40.0); } void myDisplay() { static float ang1 = 0.0, ang2=0.0; ang1 = (ang1 + 0.1); ang2 = (ang2 + 0.32); glClearColor(1.0, 0.8, 0.8, 1.0); glClear(GL_COLOR_BUFFER_BIT); gluLookAt(0,14, 15, 0, -0.5, -1.0, 0, 1, 0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3f(0.1, 0.1, 0.8); glutWireTeapot(0.5); glColor3f(0.1, 1, 0.2); glPushMatrix(); glRotatef(ang1, 0, 0, 1); glTranslatef(0,5,0); glutSolidSphere(0.2, 8, 8); glPopMatrix(); glColor3f(0.8, 0.2, 0.2); glPushMatrix(); glRotatef(ang2, 0.2, 0.2, 1.0); glTranslatef(8, 0, 0); glutSolidSphere(0.3, 12, 12); glPopMatrix(); glutSwapBuffers(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowPosition(100, 100); glutInitWindowSize(600, 600); glutCreateWindow(" opengl window creation "); glutDisplayFunc(myDisplay); glutIdleFunc(myDisplay); glutReshapeFunc(myReshape); glutMainLoop(); return 0; } |




