OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric primitives - points, lines, polygons, images, and bitmaps. OpenGL provides a set of commands that allow the specification of geometric objects in two or three dimensions, using the provided primatives, together with commands that control how these objects are rendered (drawn).

Since OpenGL drawing commands are limited to those that generate simple geometric primitives (points, lines, and polygons), the OpenGL Utility Toolkit (GLUT) has been created to aid in the development of more complicated three-dimensional objects such as a sphere, a torus, and even a teapot. GLUT may not be satisfactory for full-featured OpenGL applications, but it is a useful starting point for learning OpenGL.

GLUT is designed to fill the need for a window system independent programming interface for OpenGL programs. The interface is designed to be simple yet still meet the needs of useful OpenGL programs. Removing window system operations from OpenGL is a sound decision because it allows the OpenGL graphics system to be retargeted to various systems including powerful but expensive graphics workstations as well as mass-production graphics systems like video games, set-top boxes for interactive television, and PCs.

GLUT simplifies the implementation of programs using OpenGL rendering. The GLUT application programming interface (API) requires very few routines to display a graphics scene rendered using OpenGL. The GLUT routines also take relatively few parameters.

Rendering Pipeline

Most implementations of OpenGL have a similar order of operations, a series of processing stages called the OpenGL rendering pipeline. Although this is not a strict rule of how OpenGL is implemented, it provides a reliable guide for predicting what OpenGL will do. Geometric data (verices, line, and polygons) follow a path through the row of boxes that includes evaluators and per-vertex operations, while pixel data (pixels, images and bitmaps) are treated differently for part of the process. Both types of data undergo the same final step (raterization) before the final pixel data is written to the framebuffer.

Display Lists: All data, whether it describes geometry or pixels, can be saved in a display list for current or later use. (The alternative to retaining data in a display list is processing the data immediately-known as immediate mode.) When a display list is executed, the retained data is sent from the display list just as if it were sent by the application in immediate mode.

Evaluators: All geometric primitives are eventually described by vertices. Evaluators provide a method for deviving the vertices used to represent the surface from the control points. The method is a polynomial mapping, which can produce surface normal, colors, and spatial coordinate values from the control points.

Per-Vertex and Primitive Assembly: For vertex data, the next step converts the vertices into primitives. Some types of vertex data are transformed by 4x4 floating-point matrices. Spatial coordinates are projected from a position in the 3D world to a position on your screen. In some cases, this is followed by perspective division, which makes distant geometric objects appear smaller than closer objects. Then viewport and depth operations are applied. The results at this point are geometric primitives, which are transformed with related color and depth vlaues and guidelines for the rasterization step.

Pixel Operations: While geometric data takes one path through the OpenGL rendering papeline, pixel data takes a different route. Pixels from an array in system memory are first unpacked form one of a variety of formats into the proper number of components. Next the data is scaled, biased, processed by a pixel map, and sent to the rasterization step.

Rasterization: Rasterization is the conversion of both geometric and pixel data into fragments. Each fragment square corresponds to a pixel in the framebuffer. Line width, point size, shading model, and coverage calculations to support antialiasing are taken ito consideration as vertices are connected into lines or the interior pixels are calculated for a filled polygon. Color and depth values are assigned for each fragment square. The processed fragment is then drawn into the appropriate buffer, where it has finally advanced to be a pixel and achieved its final resting place.


OpenGL provides a powerful but primitive set of rendering command, and all higher-level drawing must be done in terms of these commands. There are several libraries that allow you to simplify your programming tasks, including the following:

Include Files

For all OpenGL applications, you want to include the gl.h header file in every file. Almost all OpenGL applications use GLU, the aforementioned OpenGL Utility Library, which also requires inclusion of the glu.h header file. So almost every OpenGL source file begins with:

#include <GL/gl.h>
#include <GL/glu.h>

If you are using the OpenGL Utility Toolkit (GLUT) for managing your window manager tasks, you should include:

#include <GL/glut.h>

Note that glut.h guarantees that gl.h and glu.h are properly included for you so including these three files is redundant. To make your GLUT programs portable, include glut.h and do not include gl.h or glu.h explicitly.

Setting Up Compilers

  • Windows Using MS Visual C++

    Installing GLUT

    1. Most of the following files (ie. OpenGL and GLU) will already be present if you have installed MS Visual C++ v5.0 or later. The following GLUT files will need to be copied into the specified directories.
    2. To install:

Compiling OpenGL/GLUT Programs

  1. Create a new project:
    • choose File | New from the File Menu
    • select the Projects tab
    • choose Win32 Console Application
    • fill in your Project name
  2. Designate library files for the linker to use:
    • choose Project | Settings from the File Menu
    • under Oject/library modules: enter "opengl32.lib glu32.lib glut32.lib"
  3. Add/Create files to the project:
    • choose Project | Add to Project | Files from the File menu
    • add the required program files
  4. Build and Execute

  • Silicon Graphics Workstation


    # insert the name of your source file here (omit the .c)
    TARGET = progname
    LIBS = -lglut -lGLU -lGL -lXmu -lXext -lXi -lX11 -lm
    CC = /usr/gnu/bin/gcc
    default: $(TARGET)
    all: default
    	$(CC) -c $<
    $(TARGET): $$@.o
    	$(CC) $@.o -Wall $(LIBS) -o $@
    	-rm -f *.o $(TARGET)

  • The bulk of this tutorial was taken from the OpenGL Programming Guide (Third Edition), The Official Guide to Learning OpenGL, Version 1.2 by Mason Woo, Jackie Neider, Tom Davis and Dave Shreiner, Silicon Graphics 1999. This tutorial was written by Lori L. DeLooze for a student project in Computer Graphics CS 580, taught by Dr. Sudhanshu Kumar Semwal, at the University of Colorado at Colorado Springs.

    Main Menu
    Back to Top