- About Us
Porting or emulation?
When I'm not in front of the computer, you can usually find me wandering up and down the computer section of the local Barnes and Noble. Almost every time go, I meet people who are interested in Linux for one reason or another, usually some techie looking for a new toy or someone who wanted to find information on "this Linux thing" they heard someone talk about. When talking to them, if they know anything about Linux, I'll normally get a lists of "can I do this?" questions, ranging from office suites to digital cameras to streaming video. A comment I'm constantly receiving is, "Yeah, it sounds great, but there are no popular games for Linux." Until recently, my answer to that was to talk about Loki and their newest game ports or about a friend who just got some Windows game running under WINE. A couple of months ago, that all changed.
Given the events that took place late January, one would think that commercial gaming on Linux would be a thing of the past. That month, the Linux world received a major blow as Loki Software, once the sweetheart of the Linux gaming scene, closed its doors to the world. Though this was a tough loss, it was not a death blow to the community, at least not if TransGaming has anything to say about it.
Both companies are responsible for bringing a number of popular formerly Windows-only games to Linux. Loki went about bringing games to Linux by porting them to Linux-native code. TransGaming, on the other hand, has taken the increasingly popular emulation road, using a modified version of WINE, called WineX. This is in line with a number of recent developments in the Linux application expansion, as can be witnessed by CodeWeavers' newest application, CrossOver Office, which uses WINE in allowing Linux users to use two formerly unattainable pieces of software on the platform: Microsoft Office and IBM Lotus Office Suite.
Though these developments are great, we have to face the underlying problem of the entire porting versus emulation debate: What's fundamentally wrong with the question?
Made for Linux
Luckily, some gaming companies have realized the potential value of releasing Linux-native video games alongside their Windows and Macintosh counterparts. The Linux community is replete with frustrated gamers, most of whom, until recently, found themselves either giving up commercial games or dual-booting for the purpose of gaming. (Hey, you might as well make use of that Microsoft tax.) Lucky for them, a batch of new commercial games is now beginning to appear on the Linux platform.
The first of these notables was Id Software's Quake III, which was the first title from a major video game company to be released simultaneously for both Windows and Linux. More recently, BioWare announced the upcoming release of its newest title, Neverwinter Nights, a Dungeons and Dragons role-playing game that is tentatively scheduled to be released on Windows, Macintosh, and Linux simultaneously. In fact, all three versions would come in the same box.
How Open Source fits into the picture
With all this going on, you might think that Open Source and commercial games don't mix. Not so, my penguin gaming friends. Not according to Sunspire Studios. With its newest title, Tux Racer, Sunspire has decided to use the Open Source model to take an Open-Sourced game commercial. With more than a million downloads, the game is already quite popular, but the question remains as to whether it will be a financially worthwhile endeavor. In Tux Racer, players race as one of four Arctic creatures through 18 downhill courses, all while gobbling up as many herring as possible. The (rather addictive) game is fun, simple to learn and is suitable for all ages.
As you can see, there are already a number of big (and not so big) players in the Linux gaming scene. The great thing is that all of the tools needed to create a 3D game are available in both forms of "free" (beer and speech). Even better is that there are already numerous projects out there that anyone interested in game programming can look at, learn from, and even help in developing. The trick is putting all the information together.
Writing Games: What you'll need
In order to begin writing your own 3D games under Linux, you need to acquire the necessary tools for the job. To a certain extent, the tools you use will be dependent upon the hardware you've got, so make sure that your hardware is supported by whatever software you decide to use. Everything that I talk about here was tested on my own humble, little system: a Pentium III 450mhz with 128mb RAM and 16mb ATI All-In-Wonder 128 video card running SuSE Linux 7.3. I'll presume that you have at least this much horse-power and that you're running a version of XFree86 4.x or greater. If you don't know what version you have running, whip out that handy-dandy virtual console and type the following command:
[gnorb@geex gnorb]$ XFree86 -version
You should get something like this:
XFree86 Version 4.1.0 / X Window System (protocol Version 11, revision 0, vendor release 6510) Release Date: 2 June 2001 If the server is older than 6-12 months, or if your card is newer than the above date, look for a newer version before reporting problems. (See http://www.XFree86.Org/FAQ) Build Operating System: SuSE Linux [ELF] SuSE Module Loader present
Most recent commercial distributions will come XFree86 4 or greater already installed, so you should be fine. If you're still in the 3.x series of XFree86, you might need to upgrade. You can check whether your video card is supported and get the latest release at the Xfree86.org Web site. You can also check there for installation information. Some distributions have easy-install packages (such as RPMs and DEBs), so make sure to check your distribution's Web site for details.
Once that's been straightened out, make sure that you can get 3D support under Linux for your video card. This normally means getting OpenGL (or an OpenGL alternative) up and running. If you've got a decent video card and are dealing with a major distro, then this shouldn't be of much concern. OpenGL, GLX (the glue that binds OpenGL to X) and the X server integration of GLX are Linux system components. They should be part of Debian, Red Hat, Mandrake, SuSE, and Caldera, as well as other distributions.
If you find that you don't have the necessary components, and you've got an ATI, Matrox, 3dfx, 3D Labs or Intel video card, then you should check out Precision Insight's DRI project status page. XFree86 4 includes DRI GLX drivers for hardware-accelerated OpenGL, so it's now just a matter of making sure that everything is set up correctly.
*A note to you SuSE users out there, you might want to check out the command switch2xxx (example: switch2xf86_glx). If it looks like everything is set up the way it should be and it still doesn't work, this will probably help you fix it.
If you're using an NVIDIA card then you're pretty much on easy street. You can download pre-compiled drivers for their chipsets from its Web site. Unfortunately, they're closed source, so if you're not comfortable with the idea of having a closed source driver near your kernel, then there's not much you can do. The specifications of NVIDIA drivers are not openly available, so there's no way to make an Open-Sourced driver for their card.
By now you should have 3D up and running. To actually start the programming process, you're going to need a few libraries and tools. You can get the Linux Game Development Center's List of packages containing (more or less) everything you need to code a game at http://lgdc.sunsite.dk/resources/category16.html. Remember, you need to understand concepts like 2D graphics and 3D-to-2D projection before you move on to things like 3D objects and complete interactive 3D worlds. If you don't yet understand these things, there are a number of books out there which can explain these concepts from top to bottom, my favorite being Norman Lin's Linux 3D Graphics Programming, published by Wordware Publishing.
What follows is a listing of some of the tools and concepts you'll need to familiarize yourself with in order to get up and running with 3D game programming under Linux, including where to get more information on the subjects.
Concepts to understand
Before you get started with functions and classes and objects (oh, my!), you have to first understand a few concepts regarding 2D and 3D graphics, at least if you want to do any serious work. You'll need to understand certain geometric and mathematical theories, like vectors, matrices, intersections, mappings and coordinate systems. To acquire this almost-forbidden knowledge, you should really try to find a good Linux 3D programming textbook, a list of which can be found at the end of this article.
In addition to 2D/3D theory, an understanding of the X Windowing System is necessary. You can get an overview of the protocol at http://www.x.org/about_x.htm. You'll need a bit of knowledge of hardware display technology and raster displays (a quick explanation of which you can find here). Once you understand this foundation, the rest is merely a matter of implementation.
Some of the basic tools
Earlier, I told you about OpenGL, something you are supposed to install on your system in order to be able to run 3D applications. OpenGL is developed by SGI and is an environment used to develop 2D and 3D graphics applications. Because of its popularity, it has become an industry standard API for cross-platform 3D and 2D application building. In fact, until recently, 3D games that were ported (or emulated) to Linux were exclusively built using OpenGL. TransGaming, however, has recently released for Linux Max Payne, a fully DirectX-based game.
Unfortunately, it's not all fun and games here. Some people don't like OpenGL due to its license, so they opt for the alternative, Mesa. Mesa, written by Brian Paul, is a free graphics library with an API almost identical to OpenGL. Programs using OpenGL can use Mesa without changing the source code, so whichever route you want to take is completely up to you and your hardware.
Alongside OpenGL/Mesa, you'll need a OpenGL/Mesa-based library to serve as a sort of glue between X and the API. That's where GLX, Utah-GLX, and GLUT come into play. GLX, as I said earlier, is the glue that connects OpenGL to the X Window System. It's required by any OpenGL implementation using X. A step beyond that is the Utah-GLX implementation, which offers a hardware accelerated GLX module for free Unix-type systems. The Utah-GLX project was born after SGI released GLX under a public source license. Utah-GLX has been included with the DRI release included in XFree86 4.x. The OpenGL Utility Toolkit (GLUT, pronounced as in glutton) is a free library written by Mark Kilgaard. It simplifies the implementation of frequently occurring OpenGL operations, and because it's built on top of OpenGL, it's compatible with Mesa.
Another important component in video game development (or multimedia in general) is the Simple DirectMedia Layer (SDL). SDL is a library that provides fast access to the graphics framebuffer and audio device. SDL doesn't actually talk to the hardware, unlike many multimedia toolkits. It instead serves as a later between the application and the underlying system. This allows SDL-dependent applications to run unchanged in any environment that SDL runs in with nothing more than an simple recompile.
Still more tools
Most major Linux distributions include the components I have just covered. If you're just interested in playing games, then these tools will generally suffice. For those of you who want to know a bit more, here is a short list of Open-Sourced tools you might need to pick up along the way. Note that a number of these are alpha and beta versions, still in development or just beginning to be developed.
*Note: you can check out a full list of modelers available for Linux at http://www.computer.privateweb.at/tech-edv/MODlinks.htm.
For more information...
Now that you have a good bird's eye view of what's involved in with programming 3D games on Linux, it's time to really dig into the subject. There are a number of resources on the Internet to assist you as you delve more deeply into the subject matter. A couple of sites to note are the Linux Game Development Center and the Linux 3D Graphics Programming information site. Both of these will contain a large amount of information, tutorials, and links regarding this subject. Personally speaking, I prefer a good book to online documentation (all other things being equal). As such, here is a list of books which might be helpful to you in case you decide to stop by your local bookstore (and if you live in Tampa, you just might see me wandering about).