Sunday, December 6, 2009

OpenGL ES Projects and iPhone SDK 3.0

If you're having problems getting any of the older OpenGL ES sample code running under SDK 3.0 - specifically if you get a white screen rather than what you're supposed to see, here is the problem - delete the line of code specified below from the App Delegate's applicationDidFinishLaunching: method:

- (void)applicationDidFinishLaunching:(UIApplication*)application
CGRect rect = [[UIScreen mainScreen] bounds];

window = [[UIWindow alloc] initWithFrame:rect]; // <-- Delete this

GLViewController *theController = [[GLViewController alloc] init];
self.controller = theController;
[theController release];

GLView *glView = [[GLView alloc] initWithFrame:rect];
[window addSubview:glView];

glView.controller = controller;
glView.animationInterval = 1.0 / kRenderingFrequency;
[glView startAnimation];
[glView release];

[window makeKeyAndVisible];


The problem is that there's already window instance in MainWindow.xib, so creating a new one is problematic - there can only be on instance of UIWindow. Under 2.2.1 and before, it worked, under 3.0, it causes problems. In both cases, the line of code should be deleted, however.


Nom DePlume said...

Thanks for posting that update...

I'd downloaded some of your NeHe portage, and was getting a blank view until I clicked the home button- at which point, the GLDisplay flashed into existence for a second and disappeared.

Sara Reid said...

One of more the exciting new features of the iPhone 3GS is its faster, more advanced graphics hardware and support of OpenGL ES 2.0. Unfortunately, Apple hasn’t provided much info at all about how to harness those new capabilities. They provide great documentation and sample code for most of their APIs, but somehow their samples and info on OpenGL has always been pretty lackluster.


Edwin said...

scrub m65 kamagra attorney lawyer body scrub field jacket lovegra marijuana attorney injury lawyer

SEO Services Consultants said...

Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck! Web Design Company