Whither CoreSurface?

The iPhone Doom port is knowingly destined never to hit the App Store, so one important question is asked:

Should I use only official (read SDK/NDA) APIs, or should I branch out into other APIs to make the game run faster?

I can't honestly answer that. I enjoy having the preference in my code, and I intend to let other have said preference when the code hits the GoogleCode project site.

So, built into the code is an #if switch, allowing you to choose whether to use the UIKit (and completely App Store-allowed) API or the private CoreSurface screen buffer API (being private, the only documentation comes from the iPhone Open Toolchain and is not covered by non-disclosure).

CoreSurface is a direct and insanely fast screen buffer, allowing you to draw graphics as fast as the hardware permits and without having to go through the CoreGraphics layers directly. Similar to the iPhone OS 1.0 code, the game can render into a CoreSurface buffer which is then displayed inside a Core Animation layer. Why would I bother doing this? For a software-rendered game like Doom, it's an order of magnitude faster than what I must do for UIKit (rendering the buffer directly into a CGImageRef and blitting that to the screen). CoreSurface is what many of the unofficial emulators and game ports use, including Zodttd's brilliant Quake 1 port to iPhone.

With CoreSurface enabled in Doom, the framerate is super-smooth and the colours are as they should be. So I will leave the option in the code for budding developers to play around with. And here's hoping Apple are given some impetus to make CoreSurface available through the public SDK, as I think the benefits would be very welcome.


  1. I say use the CoreSurface. I've tried quake4iphone and was very impressed of how smooth it ran. Looking forward to the release :-)

  2. *source code release =) It's not designed for Jailbreak, only Xcode and the SDK sandbox.

  3. I agree with Frankie, CoreSurface all the way!
    Lookin forward to seeing this one, you're doin a good job!

  4. Just curious, what kind of framerates do you get using CoreSurface? And then using UIKit/OGLES?

    Cuz I'm trying to make a 2D isometric game for iPhone, and it has been a challenge getting it to run at 30FPS.

    My dev blog can be found here: http://steverockan.blogspot.com