We'll run through the different gaming libraries you'll see under Linux.
OpenGL is a high level graphics programming API originally developed by SGI, and it
became an industry standard for 2D and 3D graphics programming. It is defined and
maintained by the Architectural Revision Board (ARB), an organization whose include SGI,
IBM, DEC, and Microsoft. OpenGL provides a powerful, complete and generic feature set for
2D and 3D graphics operations.
There are 3 canonical parts to OpenGL:
OpenGL is not only an API, it's also an implementation, written by SGI. The
implementation tries to use hardware acceleration for various graphics operations whenever
available, which depends on what videocard you have in you computer. If hardware
acceleration is not possible for a specific task, OpenGL falls back on software rendering.
This means that when you get OpenGL from SGI, if you want any kind of hardware acceleration
at all, it must be OpenGL written and compiled specifically for some graphics card.
Otherwise, all you'll get is software rendering. The same thing is true for OpenGL clones,
like Mesa.
OpenGL is the open source equivalent to Direct3D, a component of DirectX (Section 3.13). The important difference being that since OpenGL is open (and DirectX is
closed), games written in OpenGL are much easier to port to Linux while games written using
DirectX at this point in time are impossible to port to Linux.
Utah-GLX is the precursor to DRI. It makes some different design decisions,
regarding separation of data and methods of accessing the video card. (For instance, it
relies on root privileges rather than creating the kernel infrastructure necessary for
secure access). It provides support for (at this time) a couple cards which are not
well-supported in DRI. Particularly, the ATI Rage Pro family, S3 Virge (although anyone
using this for gaming is, well, nuts), and an open source TNT/TNT2 driver (which is very
incomplete). The TNT/TNT2 driver is based on reverse-engineering of the obfuscated source
code release of the X 3.3 drivers by nVidia. However, they're really incomplete, and
effectively, unusable.
As a side note, until the G400 stuff is *really* fixed in DRI, it's also the better
G400 support—but hopefully that will not be an issue by the time this HOWTO is
published.
Every once in awhile you'll see some sicko (said with respect) write a game in xlib.
It is a set of C libraries which comprise the lowest level programming interface for
XFree86. Any graphics programming in X ultimately makes use of the xlib library.
It's not an understatement to say that xlib is arcane and complicated. A program
that simply connects to an X server, puts up a window and does nothing else could be a
complicated 40 line program with arcane and very long named functions. Because of this,
there are lots of libraries which hide the details of xlib programming. Some of these
libraries focus on drawing in windows (like SDL). Other libraries are more concerned with
widgets within windows (eg pulldown menus, radio buttons and text boxes); these types of
libraries are called widget sets. Gtk is the canonical widget set on Linux, but there are
many others like fltk (a small C++ widget set), Xaw, Qt (the widget set of KDE), and Motif
(the widget set used by Netscape). Motif used to be king of the Unix world, but was very
expensive to license. The Open Group opened up Motif's license for non-commercial use, but
it was too little too late. People now use Lesstif, a Motif clone.
SDL <www.libsdl.org> is a library by Loki
Software's Sam Lantiga (graduate of UCD, yeah!). It's actually a meta-library, meaning that
not only is it a graphics library which hides the details of xlib programming, it provides
an easy interface for sound, music and event handling. It's LGPL'd and provides joystick
and OpenGL support as well. The 40 line arcane program I mentioned in the xlib section can
easily be written in 6 lines of straightforward code using SDL.
The most striking part of SDL is that it's a cross platform library. Except for a
few details about header files and compiling, a program written in SDL will compile under
Linux, MS Windows, BeOS, MacOS, MacOS X, Solaris, IRIX, FreeBSD, QNX and OSF. There are SDL
extentions written by various people to do things like handle any graphics format you care
to mention, play mpegs, display truetype fonts, sprite handling and just about everything
under the sun. SDL is an example of what all graphics libraries should strive for.
Sam had an ulterior motive for writing such a cool library. He's was the lead
programmer for Loki Software, which used SDL in all of its games except for Quake3.
DirectX is a collection of closed source and proprietary multimedia API's, first
developed by Microsoft in 1995, for its various Windows OS's. It would be a mistake to
say something like "DirectX is like OpenGL" or "DirectX is like SDL", as is commonly said in
DirectX tutorials and books. Multimedia API's are more centralized on Windows than they are on
Linux. A more accurate statement would be something like "DirectX is like DRI, OpenGL and SDL
combined". As of February 2002, the most recent version of DirectX is 8.1. The components of
DirectX are:
- DirectDraw
DirectDraw gives direct access to video memory, like DRI, so you can directly
blit 2D graphics to the video card rather than blitting the 2D graphics to main memory and
then blitting from main memory to the video card. DirectDraw is kind of like the graphical
component of SDL, but direct access to video card memory is done by DRI rather than SDL. This
is why a game can easily take out a Windows system but should never take out a Linux system.
- Direct3D (D3D)
Direct3D, like OpenGL, provides a 3D graphics API. Whereas OpenGL is open
source, lower level and compiles under a multitude of operating systems, D3D is proprietary,
higher level and only compiles on Windows. Unfortunately, most Windows game programmers
choose D3D over OpenGL and D3D is poorly supported by API translators, like wine, and
practically unsupported by virtual machines, like vmware, under Linux. D3D first appeared in
DirectX 2, released in 1996.
- DirectXAudio
Direct Audio is a combination of 2 audio API's, DirectSound and DirectMusic,
which allows direct access to the sound card for sound and music playback.
- DirectInput
DirectInput gives support for gaming input devices such as joysticks.
- DirectPlay
DirectPlay gives support for simplified networking for multiplayer gaming.
- DirectShow
DirectShow provides support for movie files like AVI and MPG. It was a
separate API from DirectX, but was integrated with DirectX 8.
- DirectSetup
This API provides a way to install DirectX from within an application. It
was designed to simplify game installation.
DirectX is "kind of" supported by winex (Section 10.4.3), poorly supported by
wine (Section 10.4.1), barely supported by vmware (Section 10.4.5) and
unsupported by Win4Lin (Section 10.4.4).
One comment about portability. Each component of DirectX has multiple corresponding
library on Linux. Moreover, a game writer which uses libraries like OpenGL, GGI or SDL will
write a game which will trivially compile on Windows, Linux and a multitude of other OS's. Yet
game companies persist using DirectX and therefore limit their audience to Windows users only.
If you're a game writer, please consider using cross platform libraries and stay away from
DirectX.
A company named realtechVR started an open source project called the "DirectX Port"
<http://www.v3x.net/directx> which, like wine, provides
a Direct3D emulation layer that implements Direct3D calls. The project was focused on the BeOS
platform, but is now focused on MacOS and Linux. The DirectX Port is open source and you can
get their latest cvs from their sourceforge page at <http://sourceforge.net/projects/dxglwrap>.