Cooking with Linux - Diners, Start Your Processors!

by Marcel Gagné

It's true, François, I feel exactly as you do. Although I realize the theme of this issue is high-performance computing, when I think high performance, I think race cars. In a strange way, mon ami, the link is a powerful one. After all, what pushes the boundaries of computing performance like great 3-D simulation? Think of it—high-performance racing driving high-performance computing. One might call that a delicious, perhaps intoxicating relationship, non?

Ah, just in time. Our guests have arrived, François. Welcome, mes amis, to Chez Marcel, home of fine Linux fare, exceptional wines and edge-of-your-seat racing action. Please sit, and make yourselves comfortable. I hope you enjoy the décor today. I had François paint racing stripes on all the tables and chairs in honor of this high-performance computing issue.

François! To the wine cellar, immédiatement! We need something to excite the senses. As I recall from my earlier quality-control tour of the cellar, the 1999 Margaret River Chardonnay from Australia is certainly exciting and has enough spirit to go the distance.

While we wait for François to return with the wine, I should tell you that every item on tonight's menu requires an accelerated 3-D video card and the appropriate XFree86 drivers, including the Mesa 3-D development libraries for compiling. All the systems here in the restaurant are ready, but if you need some information on setting up 3-D acceleration on your home Linux system, see my Linux Journal May 2003 article, “Battles inside the Computer”, for some information on direct rendering and testing your card's performance.

The first car racing simulation I remember wasn't on a computer. It was a simple, electric slot car track. The action on the figure-eight strip of black plastic was exciting. Although it was three dimensional—after all, nothing is 3-D like reality, non? —it was from an overhead viewpoint, a kind of overhead 3-D. That's the spirit behind the first item on tonight's menu, Harry Storbacka's Race.

To get Race up and running (or to get yourself up and running in Race), you can either download the static binary from the Web site or build from source. Both are available from the Race Web site at race.sourceforge.net. Obviously, the easiest thing to do is extract the binary package, but should you decide to build it from source, make sure you have the clanlib, xml2 and ode development libraries. After extracting the package, it simply should be a matter of running make as indicated below:

tar -xzvf race-0.9.0-src.tar.gz
cd race-0.9.0
make
./race

The installation is less than graceful (at least for now). I found that I had to play with the Makefile (specifically to deal with the path to my xml2 libraries), so running the available static binary certainly is much easier. Extract the source (tar -xzvf race-0.9.1-0-static-linux.tar.gz), change to the directory and run ./race-0.9.1-static. The game starts by letting you choose a few settings, including the track. You also can click Continue until the race starts. As I mentioned, the view now is from above. If you are slow on the old gas pedal, the other cars on the track will start pushing on you. The action has a kind of twisted realism to it. As the tires spin, smoke starts to rise from their tires. Press A (think accelerate) to start moving. The cursor keys turn the wheels left and right.

After spinning out on the curves a few times, I was delighted to learn that such small details were remembered in the game. When I came around for my second lap, the skid marks still were on the road. It's a cool effect.

Cooking with Linux - Diners, Start Your Processors!

Figure 1. Race's game memory remembers where you skidded out.

The real thrill of racing starts when you get behind the wheel of a car (even virtually), which explains the excitement and attraction of sit-down racers at your favorite arcade. Out there in the Linux world, you'll find a number of simulators of this type. Some are quite mature and professional, but as with the real world, cars and engines are always under development, pushing the envelope as they try to eke out a few extra revs. So it is in the world of open-source development. I'll show you a couple of these now.

One particularly promising entry is Alex Pozgaj's T1 Car Racing Simulation (t1-crs). As of this writing, the game was listed as alpha. It still was a lot of fun, though perhaps not totally playable; nevertheless, it shows great promise. If you would like to take it for a spin (in Alex's Toyata Supra), visit the T1 Web site at t1-crs.sourceforge.net. Armed with the source, follow these steps:

tar -xzvf t1-crs-0.1.2a.tar.gz
cd t1-crs-0.1.2a
./configure
make

There's no install as of yet. To play the game, stay in the build directory and type src/t1_crs.

Cursor keys control left and right motion as well as the gas and brake pedals. Make sure you gear up before starting or you may find yourself going backward. The letters Q and A on your keyboard let you gear up and down, which is absolutely necessary if you want to start moving.

Cooking with Linux - Diners, Start Your Processors!

Figure 2. Trying to Stay on the Road with the T1 Car Racing Simulation

The authors of the next item on tonight's menu, foobar and judeo, call their creation OpenGL Race Game, but I'll call it Canyon Racer to differentiate it from the other OpenGL race games featured today. Canyon Racer is another game currently in development that is nonetheless a lot of fun to play. With a hint of flavor from Star Wars' pod racers, this game puts you on a futuristic, floating vehicle careening along canyon walls. The action is fast and a little wild as you try to stay inside those walls. Above and to the left you'll find a partial map alerting you to upcoming turns. I must confess, mes amis, I had enough trouble avoiding the walls, never mind looking at the map.

Cooking with Linux - Diners, Start Your Processors!

Figure 3. The Futuristic Canyon Racer

For a copy of Canyon Racer, go to the Project Z Web site at projectz.ath.cx/?id=70 and pick up the source. As with basically all of these games, you do need a 3-D accelerated video card. To build the game, you need the OpenGL and SDL (mixer and image) libraries. With the necessary prerequisites in place, the rest is easy:

tar -xjvf racer-0.5.tar.bz2
cd racer-0.5
make

Because there is no install script, game play starts from the build directory. Type ./race, and you are on your way. Movement in the game is through the keyboard. The easiest thing is to use the cursor keys, but there are letter equivalents as well. Pressing W moves you forward; S is reverse, and A and D are left and right. Pressing the spacebar puts on the brakes. To play full screen, press the F1 key.

As mentioned, the developers consider this a game in its early stages (anyone want to help them?), but it is fun. The game's development nature shows up when you lose control and fly over a canyon wall into the non-world.

My favorite race game (and the most advanced in this roundup), is TORCS. The TORCS' Project leader Eric Espié and his team have put together a mature and advanced race simulation with beautiful graphics, photo-realistic scenery, real-time action and a lot of different cars (more than 40 at the time of this writing). If you find yourself getting bored with TORCS, perhaps it's time for you to get into the action. TORCS lets you program your own cars, robot opponents and race tracks as well. This is a game for the serious racer.

Cooking with Linux - Diners, Start Your Processors!

Figure 4. Taking to the Open Road with TORCS

For a copy of TORCS, visit torcs.sourceforge.net. The site provides binary packages for Red Hat, SuSE, Mandrake, Debian and others, as well as source (the software is GPL'd, after all). For those who really want to live on the high-performance racing edge, CVS downloads also are provided.

Building from source is pretty standard stuff, but there are a number of prerequisite libraries for 3-D development (namely Mesa and GLUT), as well as plib. The easiest way is to download one of the binary packages. Should you go that route, make sure you get everything you need. At the very least, pick up the base TORCS and TORCS-data packages. Although this is all you really need to get started, download and install some TORCS-robots, TORCS-data-cars and the TORCS-data-tracks-base packages as well. This gives you robot opponents to race against, some seriously cool places to race and that wide selection of cars I was telling you about.

You can start TORCS by typing torcs. The first thing you'll see is a simple screen offering a single-player race and an option for setup. If you are impatient, head straight for a single-player race, but you will want to come back and tweak some of those setup options. TORCS works with keyboard, mouse or joystick access, and the setup lets you tune these choices. From the setup, you also can change your player name, choose a car or track, select the type of transmission (manual or automatic) and so on. Even under the basic race menu, you can make choices, such as what kind of car you want to drive and where you want to race. I personally like being at the wheel of that red Ferrari on the Alpine track.

The action is fast and guaranteed to make your heart race. Onscreen displays show your position in the race, including current lap, as well as the status of your opponents (you sometimes pass them sitting in the ditch). It also has the standard speedometer, tachometer and fuel gauges. The top right-hand corner shows a constant frames-per-second readout, giving you an idea of your graphic card's performance, a fascinating mirror to your virtual race car's performance (my NVIDIA card ran about 75fps on average). The physics of the game are great as well. As with the overhead race game I covered at the beginning, too fast a turn sends you careening and leaving skid marks, and if you find yourself on a slope without any forward acceleration, the car starts to roll downhill.

Time has screamed by tonight, mes amis, and already I see we are approaching the checkered flag and closing time. Still, there is always time for a final glass of wine and a final race, non? François, if you would be so kind as to do the honors. Have another sip of wine, mes amis, then set down your glasses and get ready to put the pedal to the metal. Until next time, mes amis, let us all drink to one another's health. A vôtre santé Bon appétit!

Resources

Harry Storbacka's Race: race.sourceforge.net

OpenGL Race Game (aka Canyon Racer): projectz.ath.cx/?id=70

T1 Car Racing Simulation: t1-crs.sourceforge.net

TORCS: torcs.sourceforge.net

Marcel's Wine Page: www.marcelgagne.com/wine.html

Marcel Gagné (mggagne@salmar.com) lives in Mississauga, Ontario. He is the author of the newly published Moving to Linux: Kiss the Blue Screen of Death Goodbye! (ISBN 0-321-15998-5) from Addison Wesley. His first book is the highly acclaimed Linux System Administration: A User's Guide (ISBN 0-201-71934-7). In real life, he is president of Salmar Consulting, Inc., a systems integration and network consulting firm.

Load Disqus comments

Firstwave Cloud