Skip to content

Instantly share code, notes, and snippets.

@davepape
Last active January 10, 2017 18:15
Show Gist options
  • Save davepape/6527330 to your computer and use it in GitHub Desktop.
Save davepape/6527330 to your computer and use it in GitHub Desktop.
a triangle, using a pyglet vertex_list
# triangle.py
# by Dave Pape, for DMS 423
#
# Basic pyglet/OpenGL program to draw a single red triangle using a vertex list
from pyglet.gl import *
window = pyglet.window.Window()
# Create the vertex_list - 3 vertices, with 2-dimensional position data, and nothing else
vlist = pyglet.graphics.vertex_list(3, ('v2f', [0,0, 400,50, 200,300]))
@window.event
def on_draw():
glClear(pyglet.gl.GL_COLOR_BUFFER_BIT)
glColor3f(1,0,0)
vlist.draw(GL_TRIANGLES)
pyglet.app.run()
@ReblochonMasque
Copy link

15 glClear(pyglet.gl.GL_COLOR_BUFFER_BIT)
can be replaced with:
15 glClear(GL_COLOR_BUFFER_BIT)
because all pyglet.gl has already been imported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment