Googles quake2-gwt-port.

Well I am so very glad that this was not a clever April Fools on Google’s part, because running quake 2 in your browser within the HTML5 canvas tag using a version of OpenGL amongst other cutting edge technologies, aside from being one more nail in flash’s coffin is absolutely amazing and something many “techies” have seen coming for a long time but up until now had now way of explaining it to the common man!

The quake2-gwt-port was released yesterday April the 1st and like many I was dubious as to its reality due to it almost being something too good to be true, however after three hours of pain-staking building I managed to finally get it working. Due to the difficulties I encountered getting it working both under Debian with the 2.6.26-2-686 kernel and those simple problems found when doing the same within OSX, I have documented my findings here to help others in their quest at deciphering googles (at the moment) poor documentation on getting this to work!

Disclaimer

The information contained within this article is a journalised version of the notes I made while I went through the process of installing quake2-gwt-port, they have been published here for informal purposes only and you follow them at your own risk. I can not be held liable if your following the below in any way breaks your computer, just because it didn’t break mine, doesn’t mean it wont break yours. In other words getting this to work on your system can only really be done if you know what you are doing.

Compiling quake2-gwt-port under Debian

The first problem I ran into when attempting this under debian on my test server was the fact that java was not previously installed so running the following command quickly sorted that out, however it did take a few hours of searching and downloading 100MB+ files from the official JAVA website before I noticed that the second post on the google code page gave the answer.

apt-get install openjdk-6-jdk

Once java has been installed you need to install vorbis-tools and lame as these packages contain dependences that enable audio within the port, however while vorbis-tools will install through apt-get with no problems, the same can unfortunately not be said for lame. To get apt-get to install lame I had to update my /etc/apt/sources.list file with an additional source as documented within the debian wiki here and then run the following commands to update apt-get cache and install lame and vorbis-tools.

apt-get update
apt-get install lame
apt-get install vorbis-tools

As a side-effect of the aforementioned additional source added to the apt-get sources list, apt-get kicks up the following fuss when you update it following the changes to /etc/apt/sources.list:

W: GPG error: http://www.debian-multimedia.org lenny Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 07DC563D1F41B907
W: You may want to run apt-get update to correct these problems

I would ignore these, and simply remove the additional source from /etc/apt/sources.list once lame has been installed as we know it’s something we have done to cause the error, and its not stopped anything from working (yet, as far as I know).

Finally so that you can download the source from google code, you should also install mercurial, this can be done within debian and many other Linux distributions through the following apt-get command as documented here.

apt-get install mercurial

For some reason on my version of debian the shell variable JAVA_HOME was not set up by the installation of Java (openjdk-6-jdk), therefore I had to crack open nano and edit /etc/profile to include the following just before the line that reads unmask 022:

JAVA_HOME="/usr/lib/jvm/java-6-openjdk"
export JAVA_HOME

If JAVA_HOME is not set then the compile process of Quake II will fail and you would have waisted 12 minutes waiting for the command line to tell you that.

Once you have followed the aforementioned you should now have the following required packages installed mercurial, openjdk-6-jdk, lame and vorbis-tools. Your now ready to download and build Quake II for debian using the following simple steps:

  1. Load up your shell and cd into your home directory or other such workspace where your comfortable and run the following command to get a fresh copy of the code from google code:
    hg clone https://quake2-gwt-port.googlecode.com/hg/ quake2-gwt-port
  2. cd into the newly formed quake2-gwt-port directory
  3. Run ./build-dedicated-server this will build the tools and the client and server code.
  4. Next Run ./install-resources which will download, unpack, and convert the original Quake II demo resources, for reasons of copyright respect these have to be downloaded from their source and cant be packaged on google code.
  5. Due to a glitch in the way the above two commands install the code, you then have to copy the created gwtquake from maven-build/server/target/gwtquake/war/gwtquake to /war/gwtquake using the following command: cp -r maven-build/server/target/gwtquake/war/gwtquake war/qwtquake
  6. Everything is now ready to run using the command ./run-dedicated-server [port]

On my debian set-up I encountered several [WARNING] notices during the resource install but those where mostly related to character encodings and did not halt or impair the install. As I installed this on my server I have not been able to test it works within a browser due to a lack of time, however the install under osx is a much simpler affair.

Compiling quake2-gwt-port under OSX

Please Note: you must have OSX developer tools installed before you can compile anything.

As OSX does not come with vorbis-tools or lame installed you have to grab them yourself, fortunately with the fact that OSX is basically Linux with a pretty user interface doing so is very easy. To install the additional components required for the compiling of quake2-gwt-port under OSX I would recommend installing homebrew,over the much bloated MacPorts as given within the google code instructions. Installing homebrew is a very simple task indeed, first read through the online install instructions so you know what your doing then simply run the following two lines of commands:

sudo chown -R $USER /usr/local
curl -Lsf http://github.com/mxcl/homebrew/tarball/master | tar xvz -C/usr/local --strip 1

Once that has completed installing the required items for compiling the quake2-gwt-port is as simple as running the following lines of commands within OSX terminal:

brew install vorbis-tools
brew install lame
brew install mercurial

Once that is done you can continue with the instructions 1 to 6 above under the debian install guide.

Playing quake2-gwt-port under OSX

Hopefully the install went smoothly and you are now ready to play with your new toy, unfortunately just sending any old browser to http://localhost:8080/GwtQuake.html wont work as almost all modern day browsers are not compatible with HTML5, or if they are its only half an implementation due to the protocols still being on the drawing board. Two browsers that are compatible with the quake2-gwt-port are Google’s own Chromium browser and Webkit (click on links for download pages), which I presume to be the developers version of Safari due to its icon but I may be mistaken.

To get Webkit to play the game you first have to run the following command in terminal to enable webGL to be utilised by HTML5:

defaults write com.apple.Safari WebKitWebGLEnabled -bool YES

To get Chromium to play the game you have to first pass it a set of variables as you start it up, to do this, in your terminal cd to the applications folder where you have saved Chromium and run the following command to load Chromium with WebGL enabled:

./Chromium.app/Contents/MacOS/Chromium --enable-webgl --no-sandbox

Review of Game-play in Chromium and Webkit

At the moment I am unable to get the game to run in Chromium with sound, however with Webkit while audio played amazingly well as did single player, when I set it up to run the demo it crashed every time. The performance in Webkit was also noticeably better than in Chromium, with Webkit hitting 40fps at one point while Chromium lagged behind with an average of just 10fps! I have included below some screen shots of each browser playing the game and shall post updates when I get the version installed on my server working multi-player with some systems in my house.

quake2-gwt-port working with webkit

quake2-gwt-port working with chromium

If you have attempted getting this to work, like the article or have something to say, please add your comment below; I always try to respond to all comments posted here.

Leave a Reply