Skip to content

Instantly share code, notes, and snippets.

@reklis
Created July 12, 2009 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reklis/145780 to your computer and use it in GitHub Desktop.
Save reklis/145780 to your computer and use it in GitHub Desktop.
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
// create our rendering timer
[self performSelectorOnMainThread:@selector(mainGameLoop) withObject:nil waitUntilDone:NO];
}
- (void) mainGameLoop
{
while (gameRunning)
{
// Yield to system calls (touches, etc.)
while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, kGameSystemCallYield, FALSE) == kCFRunLoopRunHandledSource);
// Update the game logic.
shell->UpdateScene();
// Draw the game.
shell->RenderScene();
[_glView swapBuffers];
}
NSLog(@"game no longer running");
}
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
// create our rendering timer
[NSTimer scheduledTimerWithTimeInterval:(1.0 / kFPS) target:self selector:@selector(update) userInfo:nil repeats:YES];
}
- (void) update
{
if (!gameRunning) {
NSLog(@"game no longer running");
return;
}
if(!shell->UpdateScene())
printf("UpdateScene error\n");
if(!shell->RenderScene())
printf("RenderScene error\n");
[_glView swapBuffers];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment