Using CrashLanding as a base, I have created an app that spins a wheel with the refresh rate controlled by a NSTimer. I have a glview which is an "EAGLView" and I use it to draw my sprite that spins.
Imaging my app as a sort of "wheel of fortune" that spins to the right or left depending on users touch action. The wheel will spin when "moved" and eventually stop when let go. I start the NSTimer to call the "render" function when wheel spins and kills the timer ([timer invalidate]; timer = nil

when it stops to reduce CPU usage
However, I have noticed that when I stop the timer and started again there will be one frame that is "blank" or totally dark. I have determined it's the second frame that is blank from the time NSTimer starts. This causes the screen to seem to flash and is very annoying.
Has anyone ran into this problem before? If not, can anyone tell me a way to debug this? Could it be thread or context related since NSTimer is running it's own thread and my drawing might go into a wrong context. I'm using double buffering as I said before using the CrashLanding example.
- (void)startAnimation
{
if (animationTimer == nil )
animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(renderScene) userInfo:nil repeats:YES];
}
- (void)stopAnimation
{
[animationTimer invalidate];
animationTimer = nil;
}
- (void)renderScene {
CGRect bounds = [glView bounds];
if (rotationRate == 0){
[self stopAnimation];
}
}
[glView setCurrentContext];
glEnable(GL_BLEND);
//Draw the lander
glPushMatrix();
glTranslatef(bounds.size.width/2.0, bounds.size.height/2.0+18.0, 0);
rotation += rotateRate;
glRotatef(rotation, 0.0f, 0.0f, -1.0f);
[textures[kTexturename] drawAtPoint:CGPointZero];
glPopMatrix();
[glview swapBuffers];
}
- (void) swapBuffers
{
EAGLContext *oldContext = [EAGLContext currentContext];
GLuint oldRenderbuffer;
if(oldContext != _context) {
[EAGLContext setCurrentContext:_context];
}
glGetIntegerv(GL_RENDERBUFFER_BINDING_OES, (GLint *) &oldRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, _renderbuffer);
if(![_context presentRenderbuffer:GL_RENDERBUFFER_OES])
printf("Failed to swap renderbuffer in %s\n", __FUNCTION__);
if(oldContext != _context)
[EAGLContext setCurrentContext

ldContext];
}
Anyhelp is very appreciated.