This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Games

Linux and the art of 3D game programming

By on April 17, 2002 (8:00:00 AM)

Share    Print    Comments   

- By Norbert Cartagena -
The Linux gaming scene is not as robust as certain other operating systems, I will admit. However, the myth that there are no popular games published for the Linux platform is a thing of the past. The truth is that there are now companies publishing games for Linux. There are also Open Source projects focusing on the issue of video games, most of whom welcome assistance from anyone who offers, especially in the 3D gaming arena.
Below, I cover a couple of the most interesting recent developments in the Linux gaming world. More importantly, I will introduce some of the concepts and tools involved in 3D game programming under Linux. Note that this is not a tutorial on how to program, just an introduction to some of the projects, tools and sources of information involved with the field. For those of you who are serious about learning, I will list a number of books and other sources where you can get more information on the subject. For those of you who are not, then enjoy the article anyway. You might just learn about something you didn't know that you didn't know.

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.

    Libraries

  • ClanLib
    ClanLib is a gaming library released under the GNU General Public License that offers 2D and 3D graphics, image, sound and networking routines. The project's goal is "to allow the game developer to focus on stuff that matters, avoiding all those nasty (and boring) low level travails like setting up a directdraw window, sound mixing, reading image files, etc." ClanLib is currently at version 0.5.4 (released January 22, 2002).
  • PLib
    PLIB is a suite of portable game libraries developed by Steve Baker (co-creator of the obscenely addictive TuxKart). The project, released under the GNU Lesser General Public License (LGPL), aims to create a set of tools that allows programmers to write games and other interactive applications that are portable across a wide range of operating systems. In fact, PLIB has been used, under a modified license, to create games for Sony's PlayStation line of consoles. The PLIB suite of libraries includes sound effects, music, a complete 3D engine, font rendering, a GUI, networking, 3D math library and a collection of handy utility functions and is currently is version 1.4.2 (stable).
    3D applications, games and engines

  • Crystal Space
    Crystal Space is a free, portal-based portable 3D game development kit licensed under the LGPL. It supports "true six degrees of freedom [6DOF], colored lighting, mipmapping, portals, mirrors, alpha transparency, reflective surfaces, 3D sprites ... 32-bit display support, Direct3D, OpenGL, Glide ..." You can see the full list on its features page. There are currently about 600 people working on Crystal Space, so it's a fairly active project, the latest stable release being 0.94.
  • Descent
    Descent is a commercial, portal-based 3D game that has been Open Sourced and ported to Linux.
  • FlightGear
    FlightGear is an Open Source, multi-platform, cooperative flight simulator development project. The goal of the project "is to create a sophisticated flight simulator framework for use in research or academic environment, for the development and pursuit of other interesting flight simulator ideas, and as an end-user application." That aside, it's a heck of a lot of fun, if you like flight sims. The project is currently at version 0.7.9.
  • Tuxedo T. Penguin: A Quest for Herring
    Developed by PLIB creator, Steve and his son Oliver Baker, the Tux_AQFH project is aimed at creating a friendly search-and-explore and puzzle game with an emphasis on game-play and fun, as opposed to graphical quality (though it looks quite good). It's similar to some console games like Mario '64 and Banjo-Kazoole. The project is currently a small project, but it is a great project for anyone new to the field of game programming to sharpen their skills. From the project goals: "I'd particularly like to end up with a setup where individuals can design levels and contribute them to the game so that we all wind up with endless numbers of new levels to play and enjoy."
  • TuxKart
    This game is also developed by the father/son team of Steve and Oliver Baker. Like Tux_AQFH, TuxKart is a family friendly, extremely addicting and fun game. The project is always looking for more collaborators, so if you're looking to sink your teeth into a fun side project, then this is what you're looking for. Artist, programmers, musicians and level designers are welcome to come and help.
  • World Foundry
    Originally developed as a commercial product, World Foundry enables non-programmers to create 3D environments and games. It is a complete 3D game production environment with advanced physics, camera and scripting systems, capable of varied behavior without changing the engine itself. It has been used to create games for Windows and Sony PlayStation and is now being ported to Linux.

    3D modelers

  • 3dom
    3dom (3D Object Modeler) is a modeler licensed under the GPL. It was designed to be renderer independent.
  • AC3D
    AC3D is a 3D object/scene modeler available for various platforms (Linux, Windows 95/98/NT, Solaris, SGI, and HPUX). It's shareware and only comes in binary format.
  • Blender
    Blender is a freely available, professional 3D modeler which has been used to create 3D graphics in commercial production environments. Though it has a steep learning curve, once learned, Blender becomes a very flexible, powerful, and quick tool to work with. Unfortunately, its parent company, Not a Number (NaN) recently filed for bankruptcy (which is why I didn't link to the original hope page at http://www.blender.nl). Luckily, the program is still available from other sources, such as BlenderMind. If you already have Blender and wish to convert your files to another modeler, you can check out AC3D's python conversion scripts, which will allow Blender to export and import aC3D model files.
  • Midnight Modeler
    Midnight Modeler is a CAD-like modeler written for DOS by David R. Taylor, later ported to Linux by Michael Lamertz. It has a command line- and menu-based interface and it has tools to generate and deform meshes.
  • Pretty Poly Editor
    Pretty Poly Editor is a portable Open Source 3D modeler, file viewer and converter. Currently, it is in alpha release, so it's not very useful yet as a modeler; however, it currently serves as a good 3D file converter.
  • Sced
    Sced is a constraint-based scene editor program that makes use of geometric "constrains" to edit objects in a virtual world. It is currently version 1.03.

    *Note: you can check out a full list of modelers available for Linux at http://www.computer.privateweb.at/tech-edv/MODlinks.htm.

    Audio Projects

  • OpenAL
    The Open Audio Library (OpenAL) is "an effort to create an open, vendor-neutral, cross-platform API for interactive, primarily spatialized audio." The initiative, licensed under the LGPL, was originally started by Loki to compensate for spatialized sound above and beyond left-right panning in the Windows versions of Heretic 2 and Heavy Gear 2. It has since been used by Loki in its ports of Soldier of Fortune, SimCity 3000 Unlimited, Mindrover, and other games. Creative later developed an interest in the project and announced the initiative along with Loki during the Game Developer's Conference (GDC) in March 2000 (though Creative had expressed interest in OpenAL before then in order to complement its own driver work). OpenAL now supports a number of stereo and multi-channel formats, some of which are quite proprietary.

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).

  • Linux Game Programming by Mark "Nurgle" Collins, published by Premier Press

  • Programming Linux Games by John R. Hall, published by No Starch Press

  • Linux 3D Graphics Programming by Norman Lin, published by Wordware Publishing

  • Advanced Linux 3D Graphics Programming by Norman Lin, published by Wordware Publishing

Share    Print    Comments   

Comments

on Linux and the art of 3D game programming

Note: Comments are owned by the poster. We are not responsible for their content.

Excellent

Posted by: Anonymous Coward on April 17, 2002 10:49 PM
Excellent article. Great links (I visited some of them before). The kind of thing asking to become a mini how-to.

#

Re:Excellent

Posted by: David L. Craig on April 17, 2002 11:34 PM
What he said! This will help me in my quest to get my 16-year-old son involved who is looking at getting a degree in one of the new computer game design/development curricula like at DigiPen. I'm hoping M$ will have ceased to be the dominant game platform by the time he gets that degree.

#

Re:Excellent

Posted by: Anonymous Coward on April 19, 2002 11:18 AM
Hi,

I hope your son gets to be considered a master at game programming. Nonetheless, I foresee Windows will become an important platform for games in the near future as it loses importance in other areas (the same way DOS did and still does).

Chances are, though, if your son uses Linux (or any other Unixlike OS, BTW), he will not just be considered, but he will *be* a master. I also think some companies really develop on Unix, even when aiming at a Windows market.

Good luck, but remember: not every son is like his father. You may be forced to settle for a lesser but equally noble career, like, say, President... 8^)

#

Open Racer (Open Source Tux Racer)

Posted by: Anonymous Coward on April 18, 2002 01:55 AM
As Tux Racer went commercial, Open Racer was born. This little project seems to be currently on the back burners while the developers are hard at work in their college courses, but this is definately an interesting venture which those who want to program, or help out might want to check out:


<A HREF="http://openracer.worldforge.org/"> Open Racer </a worldforge.org>

#

Re:Open Racer (Open Source Tux Racer)

Posted by: Norbert Cartagena on April 18, 2002 08:31 AM
"The goal of the Open Racer project is to continue development and improvement of the Tux Racer game from the GPLed 0.6.1 codebase with a goal of making a game-independent 3d Extreme racing engine.Open Racer will develop in a different direction than the commercial Tux Racer in order to keep from direct competition and wasteful strife with Sunspire Studios. Note that this project is not intended in any way to compete(and probably won't be able to) with the commercial Tux Racer. In fact, I suggest that you buy Tux Racer when it comes out."

Tux Racer is still an Open Source project kept in Sourceforge. Open Racer has a different end-goal. It is another interesting 3D Open Source project, however, so thanks for the information.

#

then what?

Posted by: Anonymous Coward on April 18, 2002 01:59 AM
what about loading a object from file and moving it around in GL ... that is what would be helpful to people that is intrested in getting into 3D! .. fell free to mail me if you know about such a tourial. (andreas dot henningsson at solvus dot se)

#

Stuff

Posted by: Anonymous Coward on April 18, 2002 05:38 AM
Quake 3 was not released simultaneously on Windows and Linux, there was about a 2 week delay on the Linux version if I recall correctly. Tribes 2 was pretty close to simultaneous release. Oh and Neverwinter Nights should come out around the same time as Duke Nukem Forever.

Porting versus emulation is an easy answer, even though everyone will flame the author for his use of the term "emulation" because after all "Wine stands for 'wine is not an emulator!!'".

Look at it this way: porting is a means to an end, getting game publishers interested both financially and technically in Linux. Emulation is also a means to an end, getting games to work on Linux so well that no one even needs native applications. Lots of people like TransGaming/WineX, but their stated goal sucks, and no one thinks of the implications it seems.

#

Woah

Posted by: Anonymous Coward on April 18, 2002 05:42 AM

-"TransGaming, however, has recently released for Linux Max Payne, a fully DirectX-based game. "

TransGaming did not release this game.

TransGaming has nothing to do with this game.

#

Re:Whoa... check the link.

Posted by: Anonymous Coward on April 18, 2002 08:21 AM
Uhmm... check the link.


"Max Payne is the first major DirectX® 8-based game that the updated WineX software is able to run... TransGaming expects an updated WineX release fully compatible with Max Payne to be available in the next few weeks."

From the press release on Feb. 19, 2002

#

Re:Whoa... check the link.

Posted by: Anonymous Coward on April 18, 2002 11:33 AM
They still have nothing to do with the game.

Saying Transgaming released Max Payne is like saying that Microsoft released Max Payne, which is just as true.

#

Re:Whoa... check the link.

Posted by: Anonymous Coward on April 18, 2002 07:52 PM
Transgaming have nothing to do with Max Payne - except for getting it to work on Linux! (BTW WINEX 2.0 has just been released). Who cares if it is 'emulation' (yeah, I know, wine is not...) rather than porting. If it gets me off windows then it's got to be good. If games publishers only produce software for windows, they'll save money not writing a linux version, keeping the price of the games down. As more gamers abandon windows and move to linux it'll make more economic sense to produce cross-platform games. Question is, will gamers move from windows to linux if there is no way for them to play their favourite games? Tux Racer does not compare to the likes of Colin Mcrae II - there are very few native linux games out there, and those that exist are either based on a windows game (ie Q3 for Linux) or are years behind (ie Tux Racer - nice effort, but...)

Is there potential here for other platforms - what about Linux running XBox games, PS2, etc? MAME can do this stuff for older consoles, but this could be another killer app to get people to move to Linux.

#

Remember the Dark Ages?

Posted by: Anonymous Coward on April 18, 2002 10:30 PM
You know, the time before Loki was around and started putting out native ports. A couple games ran in wine but not many. A Linux user was left to play with wine and try in futility to get his favorite games working. Now Loki is gone, Tribsoft is gone, Hyperion doesn't do Linux anymore, and with a few small exceptions here we are, back in the Dark Ages. I personally think that sucks, and I'm doing pretty much everything I can to change it, but I'm just one guy.

Transgaming may work with a few games but it doesn't result in getting more native games. The market may not be ready, but I personally don't want to wait another 5 years before I see another native port. Even though WineX does exist, the state of Linux gaming completely sucks at this point in time, and no one seems to care as long as they can play Half-Life in WineX for $5 a month.

#

SDL?

Posted by: Anonymous Coward on April 19, 2002 02:18 AM
How 'bout the SDL library, at <A HREF="http://www.libsdl.org/">http://www.libsdl.org</a libsdl.org> - considering that Loki used this in most of their ports, it seems like it should at least be mentioned in this article.

#

Re:SDL?

Posted by: Anonymous Coward on April 19, 2002 09:59 AM
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.

You must not have read the article.

#

Re:SDL?

Posted by: Anonymous Coward on April 19, 2002 10:09 AM
Check the paragraph right above the "Still More Tools" heading. It touches on the subject. SDL's a pretty big subject, deserving of its own column. In fact, in the Documentation section, search for "SDL." You'll find a link there to an IBM tutorial on using SDL.

#

other libs

Posted by: Anonymous Coward on April 19, 2002 12:16 PM
It's pretty poor that SDL wasn't mentioned.
And there are also "comercial-quality" open-source 3d engines out there. The excellent Nebula Device (nebuladevice.sf.net) and Nevrax (www.nevrax.org, Screens: http://nevrax.org/screenshots/). And Demeter, a terrain engine, should be in that list too (www.terrainengine.com or demeter.sf.net)

regards
stephan

#

Re:other libs

Posted by: Anonymous Coward on April 19, 2002 12:23 PM
oops. SDL was mentioned. sorry. I've must been blind.

#

Thx 4 the amazing links, mainly Nevrax

Posted by: Anonymous Coward on April 21, 2002 06:58 AM
Thxs

#

Re:Thx 4 the amazing links, mainly Nevrax

Posted by: Anonymous Coward on April 27, 2002 03:03 PM
panard vision has also gone open souce, www.panardvision.com.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya