Minor performance enhancements
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)
import pygame
from pygame.locals import *
from Sprite import Sprite
+from Numeric import array,reshape
try:
from OpenGL.GL import *
#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]")
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):
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)
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()