Examples given in this page are from textbook, reference materials, and the instructor. These examples are only used for the teaching of this course.
Development Environment
C/C++ OpenGL programming is supported by major OS platforms like Windows, Linux, and Mac OS. That means, OpenGL programs are portable cross these platforms. However, in this course, we only support OpenGL program development environment on Windows OS, MinGW (32bit) C/C++ compiler, and OpenGL and freeglut libraries, as well as Eclipse C/C++, VS Code IDEs. You can download the course software from cp411_software.zip, and follow the instructions in the README.txt file to set up the development environment. Note that the MinGW compiler used in CP411 is different from that of CP264. If you use Mac machine, it is recommended to install Windows vitual machine and then the above software.
OpenGL/Glut examples by Mark J. Kilgard
- bitfont.c, print characters and right click menu
- blender.c
- bounce.c
- Selection
- logo.c
- cube.c
- dials2.c
- dinoball.c
- evaltest.c
- fontdemo.c
- glutdino.c
- glutplane.c
- highlight.c
- lightlab.c
- mjksift.c
- mjkimage.c,provides an image data
- mjkwarp.c
- mjkimage.c, provides an image data
- movelight.c
- oclip.c
- ohidden.c
- olight.c
- oversphere.c
- reflectdino.c
- sb2db.c
- scene.c
- simple.c
- sphere.c
- splatlogo.c
- stars.c
- stenciltst.c
- stroke.c
- subwin.c
Class examples
- Code examples from textbook Hearn and Baker.
- The general Bresenham line drawing function (bresenham.cpp).
- Eclipse project archive cube.zip.
- glut_test.cpp
Set up windows
Draw a line example from Ch.2
An example of using mouse
Open example of right click submenu.
Draw with key and mouse.
Example of right click menu.
Example of picking/selecting operation. - Example for bitmap read and save
- Eclipse project archive: dinosaur polyline (from Hill & Kelly's book)
- More polyline drawing examples (from Hill & Kelly's book).
- Example with mesh objects and more camera roll, pitch and yaw functions, Eclipse project archive.
- Mesh object examples: simple barn object, bucket
- code for simple ruled surfaces
Mesh object
Texture mapping examples
GLSL
- GLSL examples (2-5 from reference textbook: Interactive Computer Graphics: A Top-Down Approach with Shader-Based OpenGL, 6/E)
- see if graphics hardware supports GLSL.
- source code of the GLSL demo
- glsl_test simple example: read, compile, load and rendering with GLSL
- glsl_cube
- glsl_fractal
- gpgpu_computing, GLSL example for general purpose computing
WebGL
PyOpenGL
Ray tracing
OpenCL -- use GPU to accelerate general purpose computing.
- If you have AMD vedio card, you can add the AMD OpenCL include and library files to your minGW include and library.
- If you have NVIDIA vedio card, you can add the NVIDIS OpenCL include and library files to your minGW include and library.
- Following OpenCL examples just show OpenCL program works with MinGW and Eclipse. The same code are working on both AMD and NVIDIA GPUs.
- HelloWorld in OpenCL, MinGW and Eclipse
- Vector addition in OpenCL, MinGW and Eclipse