Skip to content

Instantly share code, notes, and snippets.

@davepape
Created September 24, 2013 12:45
Show Gist options
  • Save davepape/6684152 to your computer and use it in GitHub Desktop.
Save davepape/6684152 to your computer and use it in GitHub Desktop.
basic OpenGL transformations
from pyglet.gl import *
window = pyglet.window.Window()
triangle = pyglet.graphics.vertex_list(3, ('v2f', [0,0, 40,0, 80,80]))
@window.event
def on_draw():
glClear(GL_COLOR_BUFFER_BIT)
glLoadIdentity()
glTranslatef(300,200,0)
glColor3f(1,0,0)
triangle.draw(GL_TRIANGLES)
glColor3f(0,1,0)
glTranslatef(80,80,0)
glRotatef(45, 0, 0, 1)
glTranslatef(-80,-80,0)
triangle.draw(GL_TRIANGLES)
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment