When it comes to writing games, we spend hours artificially creating images
that take our brain and eyes only a few milliseconds to process. We rely on advanced hardware components such as powerful video cards and their software counterparts to create these magical illusions.

If you've been wondering how to build OpenGL applications on the Linux platform, then take a close look at this article and its companion piece, "OpenGL Rendering and Drawing." I'll walk you through the basic steps and put you on the path to creating your own OpenGL games and applications.

The OpenGL API

In order to make 3D application developers' lives easier, SGI developed
the OpenGL API, which was built on their earlier work with IrisGL.
OpenGL presents a uniform user/client interface to the wide range of commercial hardware
that the 3D application might encounter and will provide emulation via
software for those requested features not supported in the hardware.

With the assistance of a few freely available support libraries,
creating a simple application can require as little as a few hours of time and
a couple of hundred lines of code. Language bindings exist for
most popular
languages, including C, C++, Java, Perl, Delphi and even Visual Basic.
While a great deal of development information is available online for
OpenGL, anyone serious about developing is advised to purchase, at
minimum, the OpenGL Programmers Guide, known as the "red book." The
newly released third edition includes documentation on the latest OpenGL 1.2
extensions.

Developing OpenGL applications with Linux

Most modern desktops -- Unix, Windows, and Mac, for example -- have an OpenGL
API available, or at least a reasonable clone (such as MesaGL for Linux).
These APIs usually only include dynamic
link libraries for use by the client applications and most likely
don't include the static link libraries and/or header files
needed for compiling OpenGL clients from source.

If you want to develop OpenGL applications in the Linux environment, install Mesa GL 3.2, Mesa-devel, Mesa-glut, and Mesa-glut-devel. Having these will ensure that you have all of the tools necessary for compiling OpenGL clients. The Mesa-demos package can help you make sure that everything's installed properly.

OpenGL Hardware for Linux

OpenGL hardware for Linux is a large topic which could
fill several articles by itself. The short version is: It's fairly easy
to get full-screen acceleration now, while accelerated 3D-in-a-window
generally requires using XFree86 version 4.0. For more
details, including installation instructions, visit the
www.xfree86.org site and the
Direct Rendering Infrastructure (DRI) site on SourceForge at dri.sourceforge.net).

Compiling OpenGL programs with Mesa can require a bit of tweaking,
depending on how the "include" and "library" files are named. Some installations
name the MesaGL libraries "libMesaGL.x" instead of "libGL.x"
and may similarly name the ".h" files. This isn't a problem
as such, and in fact allows the MesaGL libraries and headers to co-exist
with the SGI SI. But you should be
aware of this if you
encounter header-include errors during the compile pass or link
errors during the link pass while trying to build a downloaded OpenGL application
from source code with only MesaGL installed.

Simply changing the requested header files and/or the Makefile
to reflect how your installation is configured is the easiest way to
fix any compile time errors. But sometimes similar errors will occur
for dynamically linked applications built on another system. In these
cases, or to be able to
build a package from source without any modifications,
copying or symbolically linking the header and library files
can often solve the problem as well. In this case Mesa is being used as
a literal "drop-in" replacement, and this demonstrates how good a clone MesaGL really is.