OpenGL (Open Graphics Library) is a software interface to graphics hardware. The interface consists of over 250 different function calls which can be used to draw complex two and three-dimensional scenes from simple geometric primitives such as points, lines, and polygons. There are also routines for rendering the scenes with control over lighting, object surface properties, transparency, anti-aliasing and texture mapping. OpenGL was developed by Silicon Graphics Inc. in 1992 to be a more 'open' (portable) version of their early SGI GL Graphics Library. OpenGL is designed as a streamlined, hardware-independent interface to be implemented on many different graphics hardware platforms.

Routines in the OpenGL graphics library can be called from most major languages. Window management is not supported in the basic version of OpenGL but there are additional libraries built on top of OpenGL which you can use for many of the things which OpenGL itself does not support.

Highlights: Fast, as it takes advantage of local graphics hardware. Portable, as it is available on all major computing platforms.

Availability and Setup

OpenGL is available on the Shared Computing Cluster (CC), as well as the Linux workstations in the Computer Graphics Laboratory (CGL). Once you have compiled your OpenGL application, you can either run it directly on one of the Linux Workstations in the CGL (the best performance as the graphics hardware is local) or you can run it remotely by setting up your application to run as an X application on the SCC or another appropriate machine and have it display to your local machine/graphics terminal.

Using OpenGL

A common way to utilize the OpenGL graphics library of routines is by making calls to the routines from C programs. In order to utilize the OpenGL library, you will need to #include <GL/gl.h> in your C program. All OpenGL library functions begin with the letters gl and capitalize words (example functions: glClear, glClearColor, and <codeglVertex2f). The OpenGL library provides a powerful but primitive set of rendering commands. Higher level libraries provide additional functionality. These include:

OpenGL Utility Library (GLU)
The GLU is included with OpenGL and built using low-level OpenGL commands. It contains routines for setting up viewing and projection matrices, polygonal tesselation and surface rendering. When using the GLU library you will need to #include <GL/glu.h> in your program. GLU routines begin with the prefix glu.
OpenGL Extension to the X Window System (GLX)
OpenGL does not include any routines for handling windowing operations so the GLX was developed to fill this gap with regard to the X Window System. Using GLX, you can enable your OpenGL programs to draw into a window under the X Window System. GLX routines begin with the prefix glx.
OpenGL Utility Toolkit (GLUT)
The GLUT is a window system-independent toolkit written to hide the complexities of differing window system APIs. It is much easier to use and more portable but far less featured than the GLX library. Functions performed include window definition, window control, and monitoring of keyboard and mouse input. GLUT also has limited support for creating pop-up menus. If you are going to use the GLUT library you will need use #include <GL/glut.h> instead of #include <GL/gl.h> in your program (Note that glut.h includes gl.h, glu.h, and glx.h automatically). GLUT routines begin with the prefix glut.

OpenGL requires the programmer to deal with the windowing system, which in our environment means the X window system. You may do this in a variety of ways. You may use straight X code, with the glx extensions for making OpenGL calls to X windows. Or you may use the GLUT toolkit to avoid dealing with the myriad of details required to work at the X level.

To get you started here is an example C Makefile for a typical GLUT based OpenGL program:

CC      = gcc

INCLUDE = -I/usr/X11R6/include
OPTIM   = -O2 -g
LIBS    = -L/usr/X11R6/lib

GLIBS   = -lGL -lGLU -lglut -lm

        $(CC) $(CFLAGS) ${OPTIM} $< ${LIBS} ${GLIBS} -o $@

To compile your C application using this Makefile you would do the following:

scc1% make Mywork.c

Depending on which additional libraries you use in your application, you might have to add additional libraries to the GLIBS line of the Makefile.

Additional Help/Documentation

We find the most useful books for learning OpenGL are the OpenGL Programming Guide, written by OpenGL Architecture Review Board, Dave Schreiner, Mason Woo, and Jackie Neider (a.k.a. the red book) and the OpenGL SuperBible written by Richard S. Wright, Benjamin Lipchak, and Nicholas Haemel.

The Boston University Computer Science department also teaches CAS CS 480/680 Introduction to Computer Graphics which covers OpenGL programming in addition to the fundamentals of computer graphics.

Online, the most useful place to visit for OpenGL information is

There are also several OpenGL tutorials available online:

  1. OpenGL API Code and Tutorial Listings
  2. OpenGL Tutorials (links to tutorials in left sidebar)
  3. Nate Robins Tutorials

We also have a simple OpenGL example of our own.