Why does my OpenGL ES iPhone game flicker when I turn on the phone for the first time?

I made a simple iPhone game using OpenGL ES. Everything works fine except for this problem:

I completely turn off the phone, then turn it on again, and then run the application, and I get this strange flicker! Every other frame is correct ... wrong frames are the same frame over and over again. If I leave the application, run it again, everything will be fine. If I leave and restart 10 times in a row, everything will be fine every time.

But if I turn off the phone, then turn on again, and then run the application, I get the same flicker the first time I start the application.

Why is this happening?!

Has anyone else had this problem?

Hooray!

+3
source share
5

Apple :

Q: OpenGL ES . iPhone 3GS, , , . ?

A: renderbuffer ( -EAGLContext/presentRenderbuffer:). renderbuffer , .

. , glClear() . , ( ) , .

, kEAGLDrawablePropertyRetainedBacking = CAEAGLLayer drawableProperties. .

+3

. OpenGL iPhone, , . , , .

, , -?

+1

, glRenderBuffer() presentRenderBuffer EAGLContext - OpenGL, glDrawElements glDrawArrays. kEAGLDrawablePropertyRetainedBacking, YES, .

kEAGLDrawablePropertyRetainedBacking drawableProperties CAEAGLLayer. . , , , . "", .

, kEAGLDrawablePropertyRetainedBacking YES , .

+1

, , , iphone OS ( ). , , . , , , , . , .

+1

/, ... 3GS, 3G, .

In my case, the problem arose when I set up the context in ESRenderer, but actually drew nothing, i.e. in the code below [scene drawing] didn’t draw anything in certain states. On older iPhones and Sims, when you don't draw anything, it doesn't seem to have flipped OpenGL buffers ... but in 3GS it does. In any case, my workaround was to stop the animation in these states (i.e., stop the timer that triggers the draw) when I did not draw anything.

- (void) draw
{
   [EAGLContext setCurrentContext:context]; 
   glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
   glViewport(0, 0, backingWidth, backingHeight);

   //Render the GLScene...
   [scene draw];

   glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
   [context presentRenderbuffer:GL_RENDERBUFFER_OES];   
}
+1
source

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


All Articles