EE 4702-1 - Code Examples

Code used in class. The links below may point to out-of-date copies, use anonymous git to retrieve the latest copies at git://dmk.ece.lsu.edu/gp. (GIT documentation.)

Dynamic Simulation Examples

These programs perform simple dynamic simulations of bouncing balls. They are intended to show how dynamic simulation is done, students are not expected to understand the gaphical code at this point in the semester.
Screenshot

Demo 1: Bouncing Ball (2016)

Shows a ball boncing on a plane. Dynamic state is just the ball position and velocity.

Screenshot

Demo 2: Springs (2016)

Shows multiple balls connected by ideal springs.

Screenshot

Demo 3: Balls (2011)

Shows management of multiple balls.

Vector, Coordinate, Matrix Examples

These programs demonstrate how to use the vector, coordinate, and matrix data types used in the programs used in the course.

Demo 0: Coor (2016)

The code shows examples of how to use the data types, but does not do anything useful.

Screenshot

Demo 1c: Coord (2016)

The use of vector arithmetic and simple transformations to place "cards" in a scene.

Screenshot

Demo 1d: Objects (2016)

The hierarchical construction of objects. Each object is constructed in its local coordinate space by instantiating and positioning other objects. The positioning is done by setting a transformation matrix.

OpenGL

These programs show use of OpenGL for graphics.
Screenshot

Demo 4: Single Triangle (2015)

A very simple OpenGL program. Just shows a purple traingle.

Screenshot

Demo 5: Sphere (2015)

Code shows tesselation of a sphere.

Screenshot

Demo 6: Lighting (2011)

Demonstrate different material properties (emissive, ambient, diffuse, specular) and lighting options.

Screenshot

Demo 7: Vertex Specification (2015)

Demonstrate use of vertex arrays and buffer objects, which are much faster ways of sending vertex data to OpenGL than using glVertex to send the data one vertex at a time. Also shows benefit of pre-computing coordinates.

Screenshot

Demo 8: Textures (2015)

Demonstration of texture application techniques and texture filtering techniques.

Screenshot

Demo 9: Vertex and Fragment Shaders (2015)

Demonstration of vertex and fragment shader for per-fragment lighting calculations. Also look at and the shader code.

Screenshot

Demo 10: Vertex and Geometry Shaders (2015)

Demonstration of vertex shaders for computing vertex points, including simple animation. Demonstration of reading buffer objects as arrays (shader storage buffers). Demonstration of using geometry shader. Also look at the shader code here and here.

CUDA

These programs demonstrate basic CUDA techniques.

CUDA Demo 1: Very Simple CUDA Program (2015)

A very simple CUDA program. No graphics.

CUDA Demo 2: CUDA Basics (2015)

Demonstration of efficient memory access patterns. Code computes the magnitudes of an array of vectors. No graphics.

CUDA Demo 3: Shared Memory (2015)

Example demonstrates use of shared memory. Code computes the average of the magnitudes of a list of vectors. Shared memory within a block is used to find the sum of the magnitudes witin a block. No graphics.

Screenshot

CUDA Demo 4: All-to-All Memory Access Patterns (2015)

The comments describe key concepts of memory access patterns and thread assignment that must be clearly understood. Demonstration of efficient global memory access patterns for code of the form: for (i=0; i<size; i++) for (j=0; j<size; j++) something(a[i],a[j]); . Comments in code show how array elements determined from threadIdx and blockIdx. Also see the host (CPU) code and the header file.

Projects' Base

Code used as baseline for course projects.
Screenshot

Bouncing Ball Simulation (Updated Fall 2013)

This code, for use as a project base and in-class demo, shows multiple techniques. These include: ball physics performed by GPU via CUDA, use of shadow volumes to stencil shadow locations, use of vertex and geometry shader to compute ball reflection locations, use of occlusion queries to limit the number of balls rendered. See also CUDA code, and Shader code.

Screenshot

Boxes and Balls Simulation (Updated Fall 2013)

File location: git://dmk.ece.lsu.edu/gp/proj-base/boxes. This code, for use as a project base and in-class demo, shows multiple techniques. These include: physics on spheres (balls) and boxes performed by the GPU via CUDA, use of shadow volumes to stencil shadow locations, use of vertex and geometry shader to compute ball reflection locations, use of occlusion queries to limit the number of balls rendered.


ECE Home Page
David M. Koppelman - koppel@ece.lsu.edu
Modified 11 May 2017 18:20 (2320 UTC)