To cleanly port my game to iPhone, I am trying to create a game loop that does not use NSTimer.
In some code examples, I noticed that if you use NSTimer, you should install it at the beginning with something like
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
where drawView will look something like this:
- (void)drawView
{
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
mFooModel->render();
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
Using this method, mFooModel displays fine, but instead I want to create my own game loop that calls drawView instead of NSTimer calling drawView 60 times per second. I would like something like:
while(gGameState != kShutDown)
{
[self drawView]
}
Unfortunately, when I do this, all I get is a black screen. Why is this happening? Anyway, can I implement what I am describing here?
, NSTimer, , AI- . /, , , . . ,
(, , , , )
.