OpenGL

OpenGL Basics

Colorful Triangle
White Paper
Sources
This is a very simple sample of OpenGL programming using GLut.
Two Quads
Sources
This sample shows how to draw two quad in a window and lets the user rotate the quads with the keyboard. It also shows why and how to setup a depth buffer.
Flat Cube
Sources
Nothing really fancy there. Just added some code to the previous sample to draw 6 quads instead of 2. 6 quads make a cube, heh.
Display List
Sources
This sample does the same as above, but uses a display list to draw the cube instead of immediate mode.
Draw Arrays
Sources
This sample does the same as above, but uses a vertex array to draw the cube instead of immediate mode.
VBO
Sources
This sample does the same as above, but uses a vertex buffer object to draw the cube instead of a vertex array. Basically, VBO are stored in the GPU memory whereas the vertex arrays are stored in the main (CPU) memory. As such. VBO can be much faster in some cases. Note that you'll need OpenGL 1.5 for this sample to work.
Trackball
Sources
This sample shows how to implement a trackball using some basic quaternion maths. This allow the user to rotate our around in a very intuitive way.
Texture (PPM)
Sources
This sample explain how to load a texture from a ppm file, which is very easy to parse, and use that texture on our cube.
Texture (PPM 2)
Sources
This part presents a much more reliable ppm loader.
Texture (TGA)
Sources
This part explains how to use TGA files for textures. This format supports transparency.
Texture (PNG)
Sources
This part explains how to use PNG files for textures. This format also supports transparency but can compress much much better than TGA.
Texture (JPEG)
Sources
This part explains how to use JPEG files for textures. This format does not support transparency but can compress much better than TGA, and often much better than png too.