Name |
Description |
Reference |
Header |
Windows |
Linux |
Mac OS X |

OpenGL |
Basic rendering calls: triangles, vertices, textures, etc. |
The OpenGL FAQ is a good place to start, or the Manual Pages. The OpenGL 1.4 Specification is unreadable legalese. The Red Book is dated but readable. |
<GL/gl.h> (note captialization, Windows people!) |
opengl32.lib (Usually have to add this to your project's linker properties...) |
libGL.so |
-framework OpenGL |

GLUT |
Create windows, set up buffers, handle keyboard and mouse. |
The original GLUT API document is readable. |
<GL/glut.h> |
glut32.lib or freeglut.lib |
libglut.so |
-framework GLUT |

GLEW |
Dynamic interface to latest OpenGL routines. A must for programmable shaders on Windows! |
GLEW makes OpenGL routines work as advertised. The only pure-GLEW routine is glewInit(). |
<GL/glew.h> (Include first; this replaces GL/gl.h!) |
(I prefer it statically linked) |
||

GLUI |
Buttons, scrollbars, dropdown menus, and other widgets. |
I've prepared some doxygen comments. There's also an older GLUI manual. |
<GL/glui.h> |
(I prefer it statically linked) | ||

ogl |
Orion's random crappy OpenGL utilities |
Read the ogl/ header files. |
"ogl/util.h", "ogl/main.h", ... |
(I prefer it statically linked) |

- glutInit, glutInitDisplayMode, glutCreateWindow, just to get something onscreen.

- glutDisplayFunc, to draw the stuff in your main window.
- glClearColor and glClear, to clear the screen before drawing.
- glBegin, to start drawing something.
- glColor3f/glColor3fv, to set the next vertex's color.

- glVertex3f/glVertex3fv, to specify a vertex's location.

- glEnd, to stop drawing.

- glutSwapBuffers, to show the stuff you've drawn so far.

- glutMouseFunc / glutMotionFunc, to track and respond to mouse events.
- glutPostRedisplay, to get your window redrawn on demand.

- glutMainLoop, to start doing graphics work.

In particular, you should know at least:

- Vectors as positions/locations/coordinates, offsets, and
unit-length directions. Know how to calculate a vector's length,
and know that "to normalize" means to make a vector have unit length by
dividing it by its length.

- Homogenous vector interpretation: (x,y,z,1) is a location; (x,y,z,0) is a direction (er, usually).
- "It's just a bag of floats" vector interpretation: the color
(r,g,b,a) can and is treated like as a vector, especially on the
graphics hardware.

- Dot product: compute the "similarity" of two vectors

- A dot B = A.x*B.x + A.y*B.y + A.z*B.z

- For unit vectors, A dot B is the cosine of the angle between A and B.

- You can figure this out if you write down the dot product of two unit 2D vectors: A=(1,0) lying along the x axis, B=(cos theta, sin theta) in polar coordinates. Then A dot B = cos theta.
- For unit vectors, A dot B is:
- 1 if A and B lie in the same direction (angle=0)

- 0 if A and B are orthogonal (angle=90)
- -1 if A and B lie in the opposite directions (angle=180)

- For any vector, A dot A is the square of A's length. For a unit vector, A dot A is 1.
- In general, A dot B = length(A) * length(B) * cos(angle between A and B)

- Dot product is commutative: A dot B = B dot A

- Dot product distributes like multiplication: A dot (B + C) = A dot B + A dot C
- Dot product is friendly with scalars: c*(A dot B) = (c*A) dot B = A dot (c*B)
- "A dot B" is the math notation. In code you usually write "float f = dot(A,B);".
- Dot product is very handy in computer graphics for lighting:
for surface normal N and light direction L, "float light = dot(N,L);".

- Coordinate frames
- A set of 3 orthogonal and normalized (orthonormal) vectors (call them S, U, and V) is magical.
- The magic is if I take any point X=s*S+u*U+v*V, then

- X dot S = (s*S+u*U+v*V) dot S

- X dot S = s * (S dot S) + u * (U dot S) + v * (V dot S)
- X dot S = s*1 + u * 0 + v * 0 (because S is unit, and S, U, and V are orthogonal)

- or X dot S = s
- That is, the 's' coordinate of the (S,U,V) coordinate system is just X dot S!

- This means I can take any point into our out of an orthonormal frame really cheaply: dot product (with each axis) to go in, scales and adds to get back out.
- To put the coordinate origin at W, just subtract W from X before dotting (or subtract W dot S after dotting)
- Cross product: compute a vector orthogonal to the source vectors

- A cross B = cross (A,B) = (A.y*B.z-A.z*B.y, A.z*B.x-A.x*B.z, A.x*B.y-A.y*B.x)
- On your right hand, if your index finger is A, and your middle finger is B, your thumb points along "A cross B".
- "A cross B" is the math notation. In code you usually write "vec3 C = cross(A,B);".

- The vector A cross B is orthogonal to both A and B. (dot(A,C) = dot(B,C) = 0)

- Cross product can be used to make any two non-orthogonal vectors A and B into an orthogonal frame (X,Y,Z). The idiomatic use is:
- X = A (pick a vector to be one axis)

- Z = A cross B (new 'Z' axis is orthogonal to A/B plane)

- Y = Z cross X
- Note that the cross product is anti-commutative: A cross B = - B cross A

#include <math.h>For a unit sphere centered at the origin, a 3D surface point v's normal vector is... v. No other surfaces work like that, but it's handy for spheres!

#define D2R (M_PI/180.0) /* degrees to radians */

double z=sin(D2R*lat);

double r=cos(D2R*lat); /* 2D radius at z cross-section */

double x=r*cos(D2R*lon), y=r*sin(D2R*lon);