Mysterious Flickering Visual Artifact
Posted
by Axis
on Stack Overflow
See other posts from Stack Overflow
or by Axis
Published on 2010-03-17T21:01:15Z
Indexed on
2010/03/18
4:41 UTC
Read the original article
Hit count: 216
A flashing bar of red appears at the top of the EAGLView that I have added as a subview in my iPhone app. It flickers on and off (i.e., one frame it's there, the next frame it's not, the next frame it's there again). I have removed a lot of code from my app until I'm essentially left with the stock OpenGL-ES project and a few changes:
The glview is not fullscreen; it's a subview.
I enabled the depth buffer.
I'm not even trying to draw anything.
If the glview is fullscreen, or if I disable the depth buffer, then there is no flicker and it works fine. But needless to say, this is a 3D view and I'd like to be able to display it within a larger UIKit view.
I'm not sure what code would be useful to post, but here's how I add the glview to my main view:
appDelegate.glView.frame = CGRectMake(245, 65, 215, 215);
[self.view addSubview:appDelegate.glView];
[appDelegate.glView startAnimation];
Here's my render function:
- (void) render
{
[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
glViewport(0, 0, backingWidth, backingHeight);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
It seems pretty obvious to me that the problem lies with the depth buffer somehow, but I'm not sure why. Also, it works fine in the simulator, but not on my iphone. I'm using iPhone OS 3.1. Any ideas on where to look for a problem?
© Stack Overflow or respective owner