Understanding computer graphics can be quite a journey. There are many resources, books and web-sites covering all aspects, but they're frequently outdated, supported by dubious or missing code and filled with maths that explain how things work, rather than how to make the lumps work. A lot of the concepts seem complex, but if you learn the right things in the right order, life can be so much easier!
A lot of the effort in developing computer graphics goes into optimisation and dealing with multiple platforms: this site is not about those issues. The code is optimised algorithmically, but needs to be valid in the future, so it is not going to be optimised for current computers or graphics cards - optimise those once you've got the code working! The exceptions are put in Global.h which is a tiny, top-level file with short Assembly Language versions of methods that cast from double to int: Floor, Truncate, Round, Mod, as well as Frac, sin and sincos (both at once).
The first graphics code used integer maths for speed because floating point processors hadn't been invented or were still far slower. All that code is now dead. Most graphics code on the Web uses float variables. floats are annoying: Writing 1 as 1.0f makes messy code! The Coding Style page explains the shape of code here, once you've downloaded it, changing it to your company's coding style shouldn't be a problem. Code here uses double throughout for holding coordinates and manipulating colors, it makes little difference now (will make less difference in the future) and keeps the code here consistent. doubles are not without their issues, though: the page [gCoord] The Trouble with double explains the use of toleranced comparisons. Quantized Serialization (saving the doubles as integers) is discussed at the bottom of the Mapping page.
Where to start
- [gCoord] The Trouble with double. Using toleranced comparisons.
- [Global] Mapping and using Normalized Intervals. Global.h is the top of the file hierarchy and exposes generally useful things like <math.h> with #define _USE_MATH_DEFINES which exposes M_PI and M_SQRT2. It has a couple of templates for Interpolation and Assmebly Language speed-ups for Truncate, Round, Floor, Frac, Mod, sincos and sinc.
- [gFilters] Interpolation: filling in missing information.
- [gVector] Vectors made easy to understand. Check out the Point and PV classes too.
- [gPlane] Planes and matrices for orientation.
- [Textures] Procedural Textures capture the imagination. Endless creative opportunities lie here!