#!/usr/bin/env python import os, sys import string from OpenGL.GL import * from OpenGL.GLU import * import pygame from pygame.locals 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): time0 = pygame.time.get_ticks() 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) pygame.display.flip() def gl_resize(self): width, height = self.res 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) glLoadIdentity() def main(self): gamequit = 0 video_flags = OPENGL|DOUBLEBUF pygame.init() res = (512,384) self.screen = pygame.display.set_mode(res, video_flags) self.res = res gl_init() self.gl_resize() used_textures = [] texture = glGenTextures(1) used_textures.append( texture) self.render() glDeleteTextures(used_textures) def test_it(): try: The_Game = gameuisys() The_Game.main() print "done" finally: pygame.quit() test_it()