#!/usr/bin/env python import os, sys import string from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * near_dist = 2 far_dist = 500 # internals def gl_init(): glClearColor(0.0, 0.0, 0.0, 0.0) glClearDepth(1.0) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) # glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) glEnable (GL_CULL_FACE) class gameuisys: def render(self): s = 0.25 glClearColor(s,s,s,1) # re-enable writing to depth buffer glDepthMask(GL_TRUE) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glutSwapBuffers() def gl_resize(self, width, height): if height==0: height=1.0 glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(67.5, 1.0*width/height, near_dist, far_dist) glMatrixMode(GL_MODELVIEW) self.main() def main(self): gamequit = 0 gl_init() glMatrixMode(GL_MODELVIEW) glLoadIdentity() used_textures = [] texture = glGenTextures(1) used_textures.append( texture) self.render() print 'textures', used_textures glDeleteTextures(used_textures) if __name__ == "__main__": game = gameuisys() glutInit(sys.argv) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH) glutCreateWindow('Lorentz Attractor Demo') glutDisplayFunc(game.main) glutReshapeFunc( game.gl_resize ) # note need to do this to properly render faceted geometry glutMainLoop()