Created
September 11, 2013 18:09
-
-
Save davepape/6527476 to your computer and use it in GitHub Desktop.
a couple simple shapes, using vertex_list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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