Black screen of .. urm .. nothingness
A number of blog readers have mentioned the problem of getting nothing but a black screen when running the earlier tutorials under SDK 3.0. This is something which has been discussed in other blog entries, but I should have really done a blog post for it a while ago to save people digging around for the solution.
Basically, in the app delegate, the following like of code
[glView mainGameLoop];
Needs to be changed to the following line of code:
[glView performSelectorOnMainThread:@selector(mainGameLoop) withObject:nil waitUntilDone:NO];
The issue seems to be that the applicationDidFinishLaunching method is run on a thread other than the main queue, so our game loop needs to be run on the main thread and hence the command above works. I’m still not 100% certain of why this happened, but when I work it out or someone can tell me I’ll pass it on.
Hope that helps.
Mike
5 Comments
Serdar on September 30th, 2009
Mike, I’ve spent more than 8 hours looking for a solution for this. I did change my project similar to yours and it started not working. Then I downloaded your project and compared and commented my code. Everything was the same but my code did not run because my project target was 3.0. I think you should change the line in download project link too.
mike on November 14th, 2009
Hi Serdar
You are absolutely right, this is something I should have changed in the earlier code. I will go back and make the changes to stop people getting caught out.
Sorry for the late response to your post, I missed the email when you first made it.
Mike
Davide on November 16th, 2009
Great! I’ve spent a lot of time trying to solve that problem.
Thank you for your great guides :D you’re explaining everything i need to know to develop my first iPhone game.
:D
Holm76 on December 29th, 2009
Hi there. Great Tutorials.
I just found these tuts a couple of days ago and are now on the way to soon producing top quality iPhone games.
I well spoken in the XNA framework from Microsoft for PC and Xbox and Im finding doing graphics programming for the iPhone a pain in the arse compared to XNA.
I also had the same error with the black screen after removing the NSTimer but I didnt waist 8 hours looking for the answer. I just turned to an older simulater and having watched the whole video I started reading all the comments for that video thinking I might not be the only one with that problem and surely somewhere in the middle I found the solution to my problem.
So maybe you should leave the error in there.. If nothing else then as a little exercise for your viewers :)
Great job.




Jason on July 8th, 2009
Mike,
I’ve noticed something weird since I upgraded to 3.0, on the device(iphone 3gs) when using openGL, sometimes while the gameloop is running the fps will go down to like 30 (from 60). It happens fairly randomly and doesn’t happen with 2.2.1(ipod touch), also it doesnt happen on the device if it’s plugged in. Just curious if you’ve seen anything like this.
Thanks, and I love the tutorials.