All notes
Opengl

Intro

Wikibooks.

Coordinates

Matrix44. There are multiple coordinate Systems involved in 3D Graphics:

OpenGLWiki. The model matrix is used to describe where an object exists in the world. The view matrix is used to describe the vantage point of our view. The view matrix can be thought of as the position and angle of a camera used to take a picture. The projection matrix is used to give our view perspective such as making close objects appear larger than distant objects. The projection matrix also provides a field of view which can be thought of as a camera lens; you can decide to use a wide-angle lens or a telephoto lens.

Cartersian Space in 3D (left), and Object Space (right).

If we want to position the cube in World coordinates at position X=5, Y=0, Z=0, multiply each vertix with the World matrix

[1,0,0,5,
 0,1,0,0,
 0,0,1,0,
 0,0,0,1]

Viewing volume

FalloutSoftware. The Viewing Volume is also known as the Clipping volume or the Frustum. Here's the visual representation of the viewing volume.

There are two planes, the viewing plane and the far clipping plane. The viewing plane is actually the screen and the far plan indicates how far you can "see", whatever is behind the far clipping plane will not be visible. The viewing volume is the space between those two planes. The viewing volume is sometimes called clipping volume because you usually want to clip your polygons against it.

VAOs, VBOs, Vertex and Fragment Shaders

OpenGLWiki.

Functions

Die. glrasterpos3f.

Culling

OpenGLWiki.

FAQ

GL3/gl3.h

OpenGL.

OpenGL and Direct3D (DirectX)

Wikibooks gives a good reference on the comparison.

GLUT

Wikibooks.

Platforms

Mac OS

Wikibooks. To use GLUT and OpenGL from within Xcode:

  1. open Xcode located in "/Developer/Applications/"
  2. choose "New Project" from the file menu
  3. choose "Command Line Tool" under the Application template for Mac OS X
  4. choose type "C++"
  5. enter your desired project name and directory
  6. Add frameworks: OpenGL and GLUT. Frameworks are stored in "/System/Library/Frameworks/", from there select and add GLUT & OpenGL.
When #including OpenGL & GLUT header files within Xcode, make sure to do so like this:
#include <OpenGL/gl.h>
#include <OpenGl/glu.h>
#include <GLUT/glut.h>

CentOS

sudo yum -y install mesa-libGL
sudo yum -y install mesa-libGL-devel

# See what versions of mesa-libGl are available for your release
yum search --showduplicates mesa-libGL

MESA

mesa3dFAQ.

About DRI

Wikipedia. The Direct Rendering Infrastructure (DRI) is a framework for allowing direct access to graphics hardware under the X Window System in a safe, efficient way. The main use of DRI is to provide hardware acceleration for the Mesa implementation of OpenGL. DRI has also been adapted to provide OpenGL acceleration on a framebuffer console without a display server running.

GLUT (OpenGL Utility Toolkit), freeglut is recommended. GLw (OpenGL widget library). Unless you're using very old Xt/Motif applications with OpenGL, you shouldn't need it.

Files

On Linux-based systems you'll want to follow the Linux ABI standard. Basically you'll want the following:

/usr/include/GL/gl.h - the main OpenGL header
/usr/include/GL/glu.h - the OpenGL GLU (utility) header
/usr/include/GL/glx.h - the OpenGL GLX header
/usr/include/GL/glext.h - the OpenGL extensions header
/usr/include/GL/glxext.h - the OpenGL GLX extensions header
/usr/include/GL/osmesa.h - the Mesa off-screen rendering header
/usr/lib/libGL.so - a symlink to libGL.so.1
/usr/lib/libGL.so.1 - a symlink to libGL.so.1.xyz
/usr/lib/libGL.so.xyz - the actual OpenGL/Mesa library. xyz denotes the Mesa version number. 

Compilation

# Find the dir location.
find /usr -type d -name dri
# Usually, /usr/lib64/dri

# --prefix=usr: Install in /usr/lib and /usr/include.
./configure --prefix=/usr --libdir=/usr/lib64 --with-dri-driverdir=/usr/lib64/dir
sudo make install

libGLw.so complains about missing function

# Check what is missing.
ldd -r /usr/lib64/libGLw.so
		linux-vdso.so.1 =>  (0x00007fff2a5ff000)
		libGL.so.1 => /usr/lib64/libGL.so.1 (0x00007f72a2c27000)
		libXt.so.6 => /usr/lib64/libXt.so.6 (0x00007f72a29c1000)
		libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007f72a2684000)
		libc.so.6 => /lib64/libc.so.6 (0x00007f72a22f0000)
		libnvidia-tls.so.346.59 => /usr/lib64/tls/libnvidia-tls.so.346.59 (0x00007f72a20ec000)
		libnvidia-glcore.so.346.59 => /usr/lib64/libnvidia-glcore.so.346.59 (0x00007f729f411000)
		libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007f729f1ff000)
		libdl.so.2 => /lib64/libdl.so.2 (0x00007f729effa000)
		libSM.so.6 => /usr/lib64/libSM.so.6 (0x00007f729edf2000)
		libICE.so.6 => /usr/lib64/libICE.so.6 (0x00007f729ebd6000)
		libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007f729e9b7000)
		/lib64/ld-linux-x86-64.so.2 (0x000000332f200000)
		libm.so.6 => /lib64/libm.so.6 (0x00007f729e733000)
		libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f729e52f000)
		libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007f729e32b000)
	undefined symbol: xmPrimitiveClassRec	(/usr/lib64/libGLw.so)
	undefined symbol: _XmStrings	(/usr/lib64/libGLw.so)

# Find what provides the missing piece.
for i in $(ls /usr/lib64/*.so); do
    echo "========="
    echo $i
    strings $i | grep -i xmPrimitiveClassRec
done

# Ahh, so it is libXm.so!!!
# ======
# /usr/lib64/libXm.so
# xmPrimitiveClassRec