commit:0dbf0d969d6d9cd665209ffc0b27820069f7a930
author:chip
committer:chip
date:Tue Nov 13 05:01:34 2007 +0000
parents:edd5c795921f73545f6021dda878a80f285b3055
Minor performance enhancements
diff --git a/Sprite.py b/Sprite.py
line changes: +1/-1
index 4e32059..191b9bb
--- a/Sprite.py
+++ b/Sprite.py
@@ -34,7 +34,7 @@ class Sprite:
 		glEnable(GL_TEXTURE_2D)
 		glBindTexture(GL_TEXTURE_2D, self.texture)
 		glColor4fv(self.color)
-		glBegin(GL_QUADS)
+		glBegin(GL_TRIANGLE_FAN)
 		x = -self.size[0]/2
 		y = -self.size[1]/2
 		glTexCoord2d(1.0,0.0)

diff --git a/bouncetest.py b/bouncetest.py
line changes: +18/-3
index 8d36490..48d8ce0
--- a/bouncetest.py
+++ b/bouncetest.py
@@ -5,6 +5,7 @@ import sys
 import pygame
 from pygame.locals import *
 from Sprite import Sprite
+from Numeric import array,reshape
 
 try:
     from OpenGL.GL import *
@@ -26,7 +27,7 @@ except IndexError:
 
 #initialize pygame and setup an opengl display
 pygame.init()
-pygame.display.set_mode(resolution, OPENGL|DOUBLEBUF)
+pygame.display.set_mode(resolution, OPENGL|DOUBLEBUF|HARDWARE)
 #pygame.display.set_mode(resolution, DOUBLEBUF)
 pygame.display.set_caption("bouncetest [loading]")
 
@@ -39,6 +40,19 @@ gluOrtho2D(0,resolution[0],0,resolution[1])
 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
 glEnable(GL_TEXTURE_2D)
 glEnable(GL_BLEND)
+glDisable(GL_DITHER)
+glShadeModel(GL_FLAT)
+glEnable(GL_CULL_FACE)
+#glDepthFunc(GL_LEQUAL)
+#glEnable(GL_DEPTH_TEST)
+glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)
+glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST)
+
+# POLYGON STIPPLING!?
+#stipple = array([[n % 2 for n in range(0,32)] + [n % 2 for n in range(1,33)] for m in range(0,16)])
+#stipple = reshape(stipple, (32,32))
+#glPolygonStippleub(stipple)
+#glEnable(GL_POLYGON_STIPPLE)
 
 class Bouncer:
 	def __init__(self):
@@ -69,7 +83,7 @@ class Bouncer:
 		self.sprite.position[1] += self.velocity[1]
 
 bouncers = []
-for i in range(0,130):
+for i in range(0,2000):
 	h = Bouncer()
 	bouncers.append(h)
 
@@ -82,7 +96,8 @@ while 1:
 	    break
 
 	#clear screen and move camera
-	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
+	#glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
+	glClear(GL_COLOR_BUFFER_BIT)
 
 	for b in bouncers:
 		b.update()