brackeen / glfm

OpenGL ES and input for iOS, tvOS, Android, and WebGL
zlib License
566 stars 77 forks source link

Background flickers first few moments of the app #46

Closed marcakafoddex closed 2 years ago

marcakafoddex commented 2 years ago

When I start my glfm based app, the first few short moments there is a bright green flash behind the rendered scene. See the video below:

https://user-images.githubusercontent.com/39903540/196430294-a12dcab6-aec0-486e-96cb-b8397d4a957d.mp4

This happens every time I minimize the app, and go back in. Also when I start the app for the first time.

It seems to be the green default Android icon that is mixed in with my rendering.

Now I've double checked that:

Is there anything glfm related that could cause this? Is there some sort of blending setting I can change in Android or something? I realize this MIGHT not be glfm related, but as of now I just don't know for certain.

Thanks in advance for any help! Marc

marcakafoddex commented 2 years ago

Okay, I figured this out now, you gotta love rubber ducking...

I did everything right except for ONE thing: I cleared my color to alpha 0.f!

So I wrote: glClearColor(0.0f, 0.0f, 0.0f, 0.f); glClear(GL_COLOR_BUFFER_BIT);

But I should have written: glClearColor(0.0f, 0.0f, 0.0f, 1.f); glClear(GL_COLOR_BUFFER_BIT);

With the alpha values set to 0, apparently Android felt the need to blend my rendering in with its own activity background or something, for the first 500 milliseconds or so.

Clearing the alpha to 1.0 immediately fixed my problem!