Thursday, December 11, 2008

An OpenGL Project Template for Xcode

I'm not a fan of the OpenGL ES Application project template that ships with the iPhone SDK. It's a pain in the ass to go in and delete the drawing code and futz with the timer, and find where they did the setup, etc. For my purposes, a much simpler template with just the skeleton of the application - a template that has places for setup and drawing code, but that doesn't give me any, is what I want.

So, I wrote one. It's been a few years since I wrote a project template - was a lot of trial and error to make sure everything worked nicely. Hopefully, I can save some people from going through the same effort: You can download the project template here.

To use it, unzip the archive and then drag the resulting folder to the following location (you may need administrator privileges to do this):
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application/Window-Based Application
I believe that there's a way to put the template under ~/Library/ somewhere, but I don't honestly know where to put it there and have it show up in the right place (as an iPhone template rather than as a Mac project template).

When you want to create a new OpenGL project, just select "Empty OpenGL Application" from the templates. This template is modeled after the GLGravity project, so it uses no nib file, and has two methods in the App Delegate for doing the initial setup of the OpenGL ES context, and then another one that gets called to do the actual drawing. The drawing frequency is controlled by a constant that is set to 60.0, but can be changed to whatever is appropriate.

Does anybody know how to assign an icon and description to a project template?

Over the next few days, I'm going to take some of the wonderful NeHe OpenGL Tutorials and port them to the iPhone and OpenGL ES. There aren't enough good, clear examples of using OpenGL ES on the iPhone, and I thought porting these might help some people (not to mention helping me get my head back into OpenGL after being away from 3D programming for quite some time).

No comments:

Post a Comment