This file contains 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
# 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 |
This file contains 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
# 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 * |
This file contains 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
# 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 |
This file contains 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() |
This file contains 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
# 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])) |
This file contains 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
# 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 * |
This file contains 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
# 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() |
This file contains 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
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() |
This file contains 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
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) |
This file contains 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
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])) |
OlderNewer