#demo_glut_3d_teapot_rotate_42_ok.py import sys from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * def display(): #glEnable( GL_LIGHTING )#need tuning #glEnable( GL_LIGHT0 )#need tuning #glEnable( GL_DEPTH_TEST )#need tuning glEnable(GL_BLEND) glColor3f ( 0.10, 0.3, 0.60 ) glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) #glClear(GL_COLOR_BUFFER_BIT) #glPushMatrix() #gluLookAt( 0,2.5,-7, 0,0,0, 0,1,0 )$cuase problem #gluLookAt(0.0,0.0,5.0, 0.0,0.0,0.0, 0.0,1.0,0.0); #glRotatef(0.01, 1, 0, 0) glRotatef(0.01, 1, 1, 0)#change color for solid teapot glutSolidTeapot( 0.5 ) glColor3f ( 0.5, 0.5, 0.70 ) #change color for wireframe glutWireTeapot(0.5) #glPopMatrix() glFlush() def reshape(w,h): glViewport( 0, 0, w, h ) glMatrixMode( GL_PROJECTION ) glLoadIdentity() gluPerspective( 45.0, 1.0*w/h, 0.1, 100.0 ) #gluPerspective( 45.0, 1.0*w/h, 0.1, 13.0 ) #gluPerspective(70, 1*w/h,0.1, 50); #https://stackoverflow.com/questions/16571981/gluperspective-parameters-what-do-they-mean glMatrixMode( GL_MODELVIEW ) glLoadIdentity() def keyboard(key,x,y): if key==chr(27): sys.exit(0) glutInit( sys.argv ) glutInit() glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA) glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH ) glutInitWindowSize( 500, 400) glutCreateWindow( b'teapot' ) #glutReshapeFunc( reshape ) #this cause the problem glutKeyboardFunc( keyboard ) glutDisplayFunc( display ) glutIdleFunc( display ) glutMainLoop()