by Chris Halsall
Figure 1. The OpenGL API was built on SGI's earlier work with IrisGL.
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.
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.
Pages: 1, 2