Skip to content

Instantly share code, notes, and snippets.

Dave Pape davepape

Block or report user

Report or block davepape

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davepape
davepape / fire.py
Created Aug 27, 2013
Basic particle system example
View fire.py
# fire.py
# by Dave Pape, for DMS 423
#
# Example particle system for a simple fire-like effect
# This code is intended as a trivial introduction to particle systems and
# graphics programming; it is NOT intended to be optimal; many values are
# hard-coded for simplicity.
#
# Requires: pyglet (http://www.pyglet.org/), euclid (https://code.google.com/p/pyeuclid/),
# and a texture image fireparticle.png
@davepape
davepape / clear.py
Created Sep 5, 2013
Minimal pyglet/OpenGL program
View clear.py
# clear.py
# by Dave Pape, for DMS 423
#
# Minimal pyglet/OpenGL program. Demonstration of the basic structure
# of such a program.
# Opens a window and clears it to all red.
# Load pyglet's OpenGL interface
from pyglet.gl import *
@davepape
davepape / triangle.py
Last active Jan 10, 2017
a triangle, using a pyglet vertex_list
View triangle.py
# 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
@davepape
davepape / shapes.py
Created Sep 11, 2013
a couple simple shapes, using vertex_list
View shapes.py
# 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()
@davepape
davepape / animtriangle.py
Created Sep 12, 2013
a triangle with one animated vertex
View animtriangle.py
# animtriangle.py
# by Dave Pape, for DMS 423
#
# draws a triangle with one moving vertex
from pyglet.gl import *
window = pyglet.window.Window()
vlist = pyglet.graphics.vertex_list(3, ('v2f', [0,0, 400,50, 200,300]))
@davepape
davepape / interp.py
Created Sep 19, 2013
interpolation demo
View interp.py
# interp.py
# by Dave Pape, for DMS 423
#
# Moves two squares by interpolation of their X position
# The timing used in the interpolation is different -
# the red square moves purely linearly; the blue square
# uses a slow-in-slow-out
import time
from pyglet.gl import *
View circle.py
# circle.py
# by Dave Pape, for DMS 423
#
# draws a circle, where the points for the vertex list are computed at run-time
from math import *
from pyglet.gl import *
window = pyglet.window.Window()
@davepape
davepape / basicXform.py
Created Sep 24, 2013
basic OpenGL transformations
View basicXform.py
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()
@davepape
davepape / interactiveXform.py
Created Sep 24, 2013
interactive transformation - simple keyboard controls
View interactiveXform.py
import sys, math, random
from pyglet.gl import *
window = pyglet.window.Window()
points = [0,0]
colors = [1,1,1]
for i in range(0,41):
angle = (i/40.0) * math.pi * 2
x,y = math.sin(angle), math.cos(angle)
@davepape
davepape / animXform.py
Created Sep 24, 2013
animated transformation
View animXform.py
from pyglet.gl import *
window = pyglet.window.Window(600,500)
triPosX = 10
triPosY = 10
triDX = 1
triDY = 1
triRot = 0
triangle = pyglet.graphics.vertex_list(3, ('v2f', [-50,-50, 50,-50, 0,50]))
You can’t perform that action at this time.