Foundations of 3D Computer Graphics

Code and Programming Exercises

The code provided here is a companion to the textbook.

Helpful Background

  1. OpenGL Documentation
  2. Setting up your machine
  3. C++ Primer



Code from the book

The code in this table mirrors the code snippets in the book. It shows you how to write a simple 2D and simple 3D program in modern OpenGL. It uses C++ only minimally. It will only run if you have full support for OpenGL 3.0.

We have since upgraded and expanded our code base significantly. The new code base uses C++ to encapsulate OpenGL resources as well as geometric objects. This allows for proper memory management handling and ultimately allows for more extensible code. It can be run with only OpenGL 2.0 support as well.

Our new code is available in the "Code and Programming exercises" section below. Though a bit more involved, we strongly encourage you to take the time and learn from the new code.
Title Chapter Notes
HelloWorld2D (book version) 1, Appendix A
HelloWorld3D (book version) 2-6 We also include the central parts of a quaternion library and the abstract interface for a rigid-body transform class.



Code and Programming exercises

This is version 2.0 of the code, January 1, 2013. Contact Steven Gortler if you require a previous version.
Title Chapter Exercise number
HelloWorld2D (new version) 1, Appendix A A.1 - A.3
HelloWorld3D (new version) 2-6 6.1 - 6.4
Quaternions + Arcball 7,8 7.1, 8.1
Hierarchical Transformations and Picking 5.4 6.6, 6.7
Keyframe Animation: Part I 9 9.1, 9.2
Keyframe Animation: Part II 9 9.3
Materials and Bump Mapping 15
Meshes and Subdivision Surfaces 22 22.1, 22.2
Furry Animation 16,23 16.1