From 5ef4e0f078e1c44742be20261e5dd126cebf2a9b Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 29 Mar 2011 01:04:19 -0400 Subject: [PATCH] pyglet_random_triangles --- benchmarks/pyglet_random_triangles.py | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 benchmarks/pyglet_random_triangles.py diff --git a/benchmarks/pyglet_random_triangles.py b/benchmarks/pyglet_random_triangles.py new file mode 100644 index 0000000..8893507 --- /dev/null +++ b/benchmarks/pyglet_random_triangles.py @@ -0,0 +1,32 @@ +import pyglet +from pyglet.gl import * +import random +import time + +window = pyglet.window.Window() + +frames = 0 +start_time = time.time() + +@window.event +def on_draw(): + global frames + global start_time + frames += 1 + if frames == 1000: + print('FPS {0:.2f}'.format(frames/(time.time()-start_time))) + frames = 0 + start_time = time.time() + + window.clear() + glClear(GL_COLOR_BUFFER_BIT) + glLoadIdentity() + for x in range(1000): + glColor3ub(random.randint(0,255), random.randint(0,255), random.randint(0,255)) + glBegin(GL_LINE_LOOP) + glVertex2f(random.randint(0,512), random.randint(0,512)) + glVertex2f(random.randint(0,512), random.randint(0,512)) + glVertex2f(random.randint(0,512), random.randint(0,512)) + glEnd() + +pyglet.app.run()