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()