You may have seen the news earlier today that an open source version of Wolfenstein 3D was released for the iPhone. John Carmack has written a lengthy, but very interesting description of the process of why it was done and how the porting the game to iPhone hardware went. If you’re interested at all in that kind of thing, it’s definitely worth a read.

As soon as I finished reading the article, I wanted to grab the source and try building the game for myself to see how it ran. Unfortunately, I couldn’t build it because I was getting a couple of errors:

"_GLimp_Shutdown", referenced from: _R_Shutdown in opengl_main.o
"_GLimp_AppActivate", referenced from: _R_AppActivate in opengl_main.o

What exactly do these errors mean? I have no idea. After about 5 minutes on Google, I couldn’t find the answer, so I started playing around, and came up with the following solution. In opengl_main.c, you’ll need to find the following lines of code, and comment out the calls to GLimp_Shutdown(); on line 366, and on line 405, comment out GLimp_AppActivate( active );. Both sections should look like the code below when you’re done.

361
362
363
364
365
366
367
368
369
370
371
372
373
374
	TM_Shutdown();
 
	/*
	** shut down OS specific OpenGL stuff like contexts, etc.
	*/
	//GLimp_Shutdown();
 
	/*
	** shutdown our OpenGL subsystem
	*/
#ifndef IPHONE
	OpenGL_Shutdown();
#endif	
}
403
404
405
406
PUBLIC void R_AppActivate( _boolean active )
{
	//GLimp_AppActivate( active );
}

The game seems to run fairly well in the iPhone Simulator, but it’s a pain to control using the mouse. (Ironic for an FPS, don’t you think?) Unfortunately, as I’m still waiting on getting a developer certificate from Apple, I can’t actually run this thing on real hardware yet.

This was the solution I found just hacking around for a moment or two, so I could start playing with the game. However, I don’t know enough about OpenGL yet to know what exactly this does, or if it’ll melt your iPhone, so use at your own risk. Honestly, I’d like to know what these lines do, and what the proper way to build this project would be. If you know, leave a note in the comments.

Of course, if you don’t want to mess with building and running the game on your own (where’s the fun in that?), the “official” release is now available in iTunes.