How To Compile Quake 3 For Raspberry Pi

This week, the Raspberry Pi Foundation celebrated 2.5 million units of the diminutive pocket-sized Linux machine. To celebrate the occasion, the foundation is working towards getting a truly open source graphics driver for the Broadcom VideoCore IV graphics core which runs the graphics on the Pi. At present, the Pi uses what is called a “binary blob” – a piece of pre-compiled proprietary software to run the Raspberry Pi graphics system. This means that the graphics driver is essentially a black box – you don’t have access to the source code.
However, Broadcom (who make the SoC) have released documentation and source code in order to make an open source graphics driver for the Raspberry Pi.

The lack of true open-source graphics drivers and documentation “is widely acknowledged to be a significant problem” for Linux on ARM, according to Upton. He adds that semiconductor company Broadcom’s recent release of full documentation for the VideoCore IV graphics core and a complete source release of the graphics stack will allow developers access to the graphics core without using the blob.

This week, the Foundation has announced a competition to win $10,000 for anyone who can get Quake 3 running at an acceptable frame-rate using these drivers.

Obviously, if you want to have a go, you’ll need to have Quake 3 running on your Pi. Since the Quake 3 engine is open source and has been for years, you can now compile Quake 3 to run on your Pi. Here, I will show you how.

First, you’ll need to download some new packages that we’ll need to download and compile the source code for Quake 3.

sudo apt-get install git gcc build-essential libsdl1.2-dev

Once you’ve done this, create a new directory under your home directory. I’ve called mine “git” as we’ll be downloading the Q3 source from GitHub using the repo clone tool.

mkdir git && cd git

Next, download the source code into this directory with: –

git clone https://github.com/raspberrypi/quake3.git

Once that has done, you’ll see a new directory called (predictably) “quake3”. Change to that directory. You’ll need to modify the build script for the ARM CPU next.

vi build.sh

Change the following lines so that they look like this: –

ARM_LIBS=/opt/vc/lib
INCLUDES="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads"
#CROSS_COMPILE=bcm2708-

If you’re using a Raspberry Pi 3, you also need to change this line further down of the build.sh file, commenting out the -lvmrpc_client so that it reads: –

# sdl not disabled
make -j4 -f Makefile COPYDIR="$BASEQ3_DIR" ARCH=arm 
        CC=""$CROSS_COMPILE"gcc" USE_SVN=0 USE_CURL=0 USE_OPENAL=0 
        CFLAGS="-DVCMODS_MISC -DVCMODS_OPENGLES -DVCMODS_DEPTH -DVCMODS_REPLACETRIG $INCLUDES" 
        LDFLAGS="-L"$ARM_LIBS" -L$SDL_LIB -lSDL -lvchostif -lvcfiled_check -lbcm_host -lkhrn_static -lvchiq_arm -lopenmaxil -lEGL -lGLESv2 -lvcos -lrt"

Note that the CROSS_COMPILE directive has been commented out. Save this file and return to the command line. The assets for Quake 3 (artwork, models, graphics, levels etc) are not open source – so you’ll have to use either the original resources from the Quake 3 CD (if you still have it!) or use the demo resources. We’ll use the demo resources which you can download from my server with:-

wget http://joshua14.homelinux.org/downloads/Q3-Demo-Paks.zip

Once you’ve downloaded this, unzip it with: –

unzip Q3-Demo-Paks.zip

This will give you a new directory called “baseq3”. I’ve downloaded this to my “/home/pi/downloads” directory, so in the build.sh script, change the BASEQ3_DIR directive so that it points to your downloaded baseq34 directory like so: –

BASEQ3_DIR="/home/${USER}/downloads/"

Once you’ve done that and re-saved the build.sh script, you can start the compile by running “./build.sh”. Quake 3 will now compile – don’t worry about any warnings you get. This process takes between 30 and 60 minutes on the Raspberry Pi.

Once this is all done, you can copy the build directory and rename it to something more descriptive like so: –

cp -R ~/git/quake3/build/release-linux-arm ~/quake3

This copies the build directory with the game to /home/pi/quake3. To run the game, you need to execute the following: –

 ~/quake3/ioquake3.arm

This will start the game. If you get errors, check that the pak files have been copied to the ~/quake3/baseq3 sub-directory. When the game starts, if you’re just using the demo resource files, just click “Accept”. Obviously, if you’ve installed the resource files from a legit Quake3 CD you already have your CD key :D
If you want to create a launcher icon on your desktop for Quake3, change to your Desktop directory with: –

cd ~/Desktop

and create a file called “quake3.desktop”. Put in the following: –

[Desktop Entry]
Name=Quake 3
Comment=Launch Quake 3
Exec=sh -c 'cd ~/quake3 && ./ioquake3.arm'
Icon=/home/pi/quake3/q3icon.jpg
Terminal=false
Type=Application
Categories=Application;Games;
StartupNotify=true

Save this, and return to the command line. You’ll need an image to use as the Quake 3 icon, so search for and download something suitable from Google Image Seaqrch. Remember that the icon must be in JPG format (not PNG or anything else). It doesn’t matter too much about the size as the icon will be scaled down. As you can see from the Icon entry in the desktop file, I’ve called mine “q3icon.jpg” which is being loaded from the “/home/pi/quake3” directory.

That’s it – happy gaming and if you’re feeling very brave, perhaps try the open source graphics drivers and a bit of coding in order to win yourself ten grand :D

, , ,