[PyOpenGL-Users] help!!
Brought to you by:
mcfletch
From: Eric G. <eri...@ep...> - 2007-10-02 12:38:30
|
PyOpenGL users, Does someone can tell me why the following code does not work? I only get black screen? Thanks in advance!! Eric. *from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * from math import * def display(): global obj1 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) materialColor = [0.1745, 0.0, 0.1, 0.0] #the light scattered off the environment diffuseColor = [0.1, 0.0, 0.6, 0.0] #the light rays coming directly from source specularColor = [0.7, 0.6, 0.8, 0.0] #the light reflected off a shiny surface shininess = 80 glMaterialfv(GL_FRONT, GL_AMBIENT, materialColor) glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseColor) glMaterialfv(GL_FRONT, GL_SPECULAR,specularColor) glMaterialf(GL_FRONT, GL_SHININESS, shininess) glPushMatrix() glTranslated(0.0,0.0,0.0) gluSphere(obj1, 3.0, 50, 50) glPopMatrix() glFlush() #glutSwapBuffers() def init(): glClearColor(0, 0, 0, 0) glMatrixMode(GL_PROJECTION) glLoadIdentity() glLightfv(GL_LIGHT0, GL_AMBIENT, [0.0, 0.0, 0.0, 1.0]) glLightfv(GL_LIGHT0, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0]) glLightfv(GL_LIGHT0, GL_POSITION, [0.0, 3.0, 3.0, 0.0]) glLightModelfv(GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0]) glEnable(GL_LIGHTING) glEnable(GL_LIGHT0) if __name__ == "__main__": global obj1 obj1 = gluNewQuadric() glutInit([]) glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB) glutInitWindowSize(250, 250) glutCreateWindow('Hello GLUT') #glutSetDisplayFuncCall(display) glutDisplayFunc(display) #gluQuadricDrawStyle(obj1, GLU_FILL) init() glutMainLoop()* -- / "Love, Gift from Life, is given naturally." / Eric Germaneau <http://lcr.epfl.ch/page37437.html> Ecole polytechnique fédérale de Lausanne (EPFL) FSB - IPMC Laboratoire de Cristallographie(LCr) <http://lcr.epfl.ch> BSP 518 CH-1015 Lausanne Switzerland eri...@ep... <mailto:eri...@ep...> /Tel./: +41 (0)21 / 693 06 36 /Fax./: +41 (0)21 / 693 05 04 /msn/: ai...@ho... /skype/: aihaike /Please consider the environment before printing this email - Considérez svp l'environnement avant d'imprimer cet email/ |