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

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

Screenshot

Demo 2: Springs

Shows multiple balls connected by ideal springs.

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

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

Screenshot

Demo 1c: Coord

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

Screenshot

Demo 1d: Objects

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

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

Screenshot

Demo 5: Sphere

Code shows tesselation of a sphere.

Screenshot

Demo 6: Lighting

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

Screenshot

Demo 7: Vertex Specification

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

Demonstration of texture application techniques and texture filtering techniques.

Screenshot

Demo 9: Vertex and Fragment Shaders

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

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

A very simple CUDA program. No graphics.

CUDA Demo 2: CUDA Basics

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

CUDA Demo 3: Shared Memory

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

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

Link-Connected Spheres Simulation

The code simulates systems made of spring and point masses, rendered to look like spheres and curved cyclinders. Shader code is used for the curved links, among other effects, and CUDA code is used for the physics.

Screenshot

Bouncing Ball Simulation

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

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 28 Jun 2023 14:02 (1902 UTC)
Provide Website Feedback  • Accessibility Statement  • Privacy Statement