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.



I tried that fix and after the splash screen, I get thrown into the debugger with this sound library initialization error. I’m compiling in XCode under the 2.2 iPhone simulator.
[Session started at 2009-03-24 17:35:33 -0700.]
Console Initialized
—— Display Initialization ——
Initializing OpenGL Subsystem
GL_VENDOR: Apple Computer, Inc.
GL_RENDERER: Apple Software Renderer
GL_VERSION: OpenGL ES-CM 1.1 APPLE
GL_EXTENSIONS: GL_OES_compressed_paletted_texture GL_OES_mapbuffer GL_OES_point_size_array GL_OES_read_format GL_OES_texture_mirrored_repeat GL_OES_point_sprite GL_OES_framebuffer_object GL_OES_blend_subtract GL_EXT_texture_lod_bias GL_OES_depth24 GL_OES_rgb8_rgba8 GL_IMG_read_format GL_IMG_texture_compression_pvrtc GL_IMG_texture_format_BGRA8888
GL_MAX_TEXTURE_SIZE: 1024
glGetError() = 0×501
Console Initialized
Cmd_AddCommand: “toggleconsole” already defined
Cmd_AddCommand: “clear” already defined
Cmd_AddCommand: “conDump” already defined
——- Sound Initialization ——-
…Initializing OpenAL subsystem
…calling dlopen( /System/Library/Frameworks/OpenAL.framework/OpenAL ): succeeded
[Session started at 2009-03-24 17:35:43 -0700.]
Failed to initialize OpenAL
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
[...] thanks to John Carmack for putting the source code out too, and thanks to Josh Buhler for saving me the trouble of resolving the compile errors [...]
[...] het oude ‘Wolfenstein 3D‘. De broncode is uitgebracht onder een GPL licentie. Met wat hulp bij het compileren draait het nu ook op de iPhone simulator op m’n laptop, en dus ook op [...]
I attempted this quick-fix that you suggested and it worked like a charm. Those were the two calls that the compiler was having a problem with. We’ll have to investigate why this is necessary within the simulator.
I’m betting we see a post about this by John C. himself tomorrow.
Karl, make sure you’re running it in the proper version of the simulator that matches your current sdk version.
That error is a sign of a dll mismatch.
[...] on the iPhone simulator you need to make some minor code modification. Instruction can be found at ghostradio.net Share and [...]