- def init():
- ...
- glEnable(GL_NORMALIZE)
- glEnable(GL_LIGHTING)
- glEnable(GL_LIGHT0)
- glEnable(GL_CULL_FACE)
- glMatrixMode(GL_MODELVIEW)
- ...
- def display():
- """ Render all objects"""
- global boundingBox, rotX, rotY, rotZ, rotVals, pointList, shiftX, shiftY, mouseScaleFactor, colorFg, colorBg, colors, faceList, dspList
- #set clear color
- glClearColor(colors[colorBg][0], colors[colorBg][1], colors[colorBg][2], 1)
- #clear with clear color. IMPORTANT - must be executed after glClearColor()!!!
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
- glPushMatrix()
- # 5. Scaling for middle mouse button
- glScalef(mouseScaleFactor, mouseScaleFactor, mouseScaleFactor)
- # 4. Move
- glTranslate(shiftX, shiftY, 0)
- # 3. rotate
- glRotate(rotX, 1, 0, 0)
- glRotate(rotY, 0, 1, 0)
- glRotate(rotZ, 0, 0, 1)
- # 2. Scale to [-1, 1]
- scalefactor = 2/boundingBox.values['maxLength']
- glScalef(scalefactor, scalefactor, scalefactor)
- # 1. Move to center
- glTranslate(-boundingBox.values['mitteX'], -boundingBox.values['mitteY'], -boundingBox.values['mitteZ'])
- light_position = [0, 0, -5.0, 1.0]
- glLightfv(GL_LIGHT0, GL_POSITION, light_position)
- glCallList(dspList)
- glPopMatrix() #Pop Matrix from Stack
- glutSwapBuffers() #swap buffer