Porting a iPhone OpenGL ES Game to OS X

I needed to show a demo of my game to some one who has a Mac, but no iPhone. There are two ways you can do this:

  1. Just run the iPhone game via the emulator. This is quite messy because you need to get a non technical person to download and install xcode and install the game in the correct directory.
  2. The second way is to actually port the code to OS X. This turned out to be easier than expected, thanks to the fact that the game is already built to be portable, mainly using OpenGL ES and OpenAL.

The secret here is to use GLUT. I started by making a blank GLUT project using these instructions. Then, I converted my touch handling code using glutMouseFunc and glutMotionFunc. Using GLUT is actually a lot simpler than the standard OpenGL initialisation code used in EAGLView.
Then, I had to convert my PVR textures to normal textures. (Funnily enough the PVR code compiles fine – but obviously does not run). Finally, OpenGL functions ending with ‘x’ have to be changed to ‘i’, e.g.: glTexParameterx becomes glTexParameteri. Also, glOrthof becomes glOrtho and glFrustumf becomes glFrustum.
I didn’t need to make any changes at all to OpenAL, that just worked.

This entry was posted in iPhone development and tagged , , , , . Bookmark the permalink.

3 Responses to Porting a iPhone OpenGL ES Game to OS X

  1. Nick says:

    Hi Ed,

    Just a question about this – you don’t mention porting shader code. I presume this is because you were using OpenGL ES1.1 and not OpenGL ES 2.0 at the time of writing this post?

    Your advice greatly appreciated,


  2. Nick says:

    Ignore my prior comment – yes I see from the glOrtho etc. that you were using ES 1.1. Never mind 🙂

    • Ed Welch says:

      Yep, it’s 1.1. That post is pretty old.
      Shaders shouldn’t need any porting, except if you are using OpenGL extensions (for instance, shadow2DProj becomes shadow2DProjEXT)

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: