IPhone OpenGL First Frame Black

My application is based on OpenGL and supports ES 1.1 as well as ES 2.0.

My view controller has a view, which is an instance of EAGLView (according to Apple's sample code), which, in turn, uses different "rendering" objects for ES 1.1 or 2.0 (pretty standard for everyone who used Xcode samples).

I use CADisplayLink to update the screen. I am aiming for a minimum of iOS 4.0+, so there should be no problems.

When starting, the first frame is displayed after the initial image (Default.png), it is displayed in black. A one-time, annoying black flicker between them.

If before creating the Key and Visible windows, I fake one round of the update / render cycle (to have a back buffer, and also not empty), the flicker disappears, but only when using ES 2.0 .

I have kEAGLDrawablePropertyRetainedBacking set to YES, but no value has any meaning.

When using ES 1.1, flicker remains. The only difference is that if I perform an “update” before making the window visible, the screen flickers to the color that I specify with glClearColor (). But if I don’t pre-refresh, the flicker is always black.

I discussed this issue over and over again in the Cocos2d forums, but even there the problem seems to always come back and bite you after every new hack.

, plain-OpenGL ES ( Cocos2d ) , ...

?

+3
4

, - (.. Default.png ), . CADisplayLink .

, viewDidLoad:, , , NIB. , , .

, , , - , ( ). , UIImageView, Default.png . UIImageView. .

+4

, presentRenderbuffer ( glBindRenderbuffer , ), . - GLView Renderbuffer -. , , .

+1

You need to redraw the scene in the method of layoutSubviewsyour OpenGLView class.

-(void)layoutSubviews {
    GLint backingWidth, backingHeight;

    glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
    [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer];
    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth);
    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight);

    glViewport(0, 0, backingWidth, backingHeight);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    [scene draw];
    [context presentRenderbuffer:GL_RENDERBUFFER];
}
0
source

I had a similar problem when opening eaglview in a view-based application. I had a flicker flash second of a black screen, and then the opening opens. What worked just did eaglLayer.opaque = NO;in the initWithCodermethod in the class EAGLView.

-1
source

Source: https://habr.com/ru/post/1794658/


All Articles