We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 847

Summary: SDL Initializes but does not draw to the window with iPhone 3.0 SDK
Product: SDL Reporter: Yevgeniy Goyfman <yevgeniy>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2 CC: queries
Version: 2.0.0   
Hardware: iPhone/iPod touch   
OS: iOS 4   

Description Yevgeniy Goyfman 2009-10-15 07:32:04 UTC
Steps to replicate:

1)  Compile and run any of the Demo projects for iPhone 3.0
2)  Screen will display SLD "Loading" screen
3)  SDL "Loading" screen is not replaced by the application's graphics/UI

Demo apps are being compiled under OSX 10.6 with XCode 3.2

Please note that compiling for iPhone 2.x targets works fine.  There are no errors reported by SDL or by iPhoneOS itself during the execution of the program
Comment 1 Roger Willcocks 2009-10-25 08:45:37 UTC
appDidFinishLaunching is triggered before all the setup's complete. The easiest fix is to arrange for another event to be sent when it's really ready, and run SDL_main from there. Ref. http://blog.rightsprite.com/2008/11/iphone-applicationdidfinishlaunching.html

SDL-1.3.0-4563/src/video/uikit/SDL_uikitappdelegate.m:



- (void)postFinishLaunch {
	
	/* run the user's application, passing argc and argv */
	int exit_status = SDL_main(forward_argc, forward_argv);
	
	/* free the memory we used to hold copies of argc and argv */
	int i;
	for (i=0; i<forward_argc; i++) {
		free(forward_argv[i]);
	}
	free(forward_argv);	
		
	/* exit, passing the return status from the user's application */
	exit(exit_status);
		
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {
			
	/* Set working directory to resource path */
	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];

	[self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
}
Comment 2 Sam Lantinga 2009-11-01 23:56:19 UTC
This fix works great, thanks!