Commits

Owen Nelson committed de523f4

using batch rendering

Comments (0)

Files changed (1)

 grid_h = None
 window = pyglet.window.Window()
 fps_display = pyglet.clock.ClockDisplay()
+batch = pyglet.graphics.Batch()
 
 
 def draw(state):
         bottom_left = (grid_w * x, grid_h * (y + 1))
         bottom_right = (grid_w * (x + 1), grid_h * (y + 1))
 
-        pyglet.gl.glColor3f(v, v, v)
-        pyglet.gl.glBegin(pyglet.gl.GL_QUADS)
-        pyglet.gl.glVertex2f(*top_left)
-        pyglet.gl.glVertex2f(*bottom_left)
-        pyglet.gl.glVertex2f(*bottom_right)
-        pyglet.gl.glVertex2f(*top_right)
-        pyglet.gl.glEnd()
-        pyglet.gl.glColor3f(1, 1, 1)
+        batch.add(4, pyglet.gl.GL_QUADS,
+            None,
+            ('v2f', top_left + bottom_left + bottom_right + top_right),
+            ('c3f', (v, v, v) * 4)
+        )
 
         it.iternext()
 
     window.clear()
     frame = game.next()
     draw(frame)
+    batch.draw()
     fps_display.draw()