Skip to content

Instantly share code, notes, and snippets.

@davepape
Created September 11, 2013 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davepape/6527476 to your computer and use it in GitHub Desktop.
Save davepape/6527476 to your computer and use it in GitHub Desktop.
a couple simple shapes, using vertex_list
# shapes.py
# by Dave Pape, for DMS 423
#
# draw three shapes using two vertex lists - one vertex list for a yellow triangle,
# the other for a triangle strip and a line strip
from pyglet.gl import *
window = pyglet.window.Window()
vlist1 = pyglet.graphics.vertex_list(3, ('v2f', [0,0, 400,50, 200,300]), ('c3f', [1,1,0, 1,1,0, 1,1,0]))
vlist2 = pyglet.graphics.vertex_list(6, ('v2f', [200,300, 300,300, 250,350, 350,350, 275,400, 450,425]))
@window.event
def on_draw():
glClear(pyglet.gl.GL_COLOR_BUFFER_BIT)
vlist1.draw(GL_TRIANGLES)
glColor3f(1,0,0)
vlist2.draw(GL_TRIANGLE_STRIP)
glColor3f(0,1,1)
vlist2.draw(GL_LINE_STRIP)
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment