views:

47

answers:

1

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:

  1. The glview is not fullscreen; it's a subview.

  2. I enabled the depth buffer.

  3. 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?

A: 

Well, I arbitrarily changed the width of the glview and it fixed it. I still don't know what the original cause of the problem was.

whooops
I know this is a long shot but check for something silly like this problem I had long ago: http://stackoverflow.com/questions/1039208/opengl-light-flickering-when-i-update-its-position-each-frame - maybe it'll give you some idea. Or maybe it was just a bug?
Ricket