pyglet_random_triangles
This commit is contained in:
parent
b48846ee21
commit
5ef4e0f078
32
benchmarks/pyglet_random_triangles.py
Normal file
32
benchmarks/pyglet_random_triangles.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user