我使用 OpenGL ES 为 iPhone 制作了一个简单的游戏。除了这个问题之外,一切正常:
我将手机完全关闭,然后重新打开,然后启动我的应用程序,然后出现奇怪的闪烁!其他所有帧都是正确的……不正确的帧只是一遍又一遍地出现相同的帧。如果我退出该应用程序,再次启动它一切都很好。如果我连续退出并重新启动 10 次,每次都一切正常。
但是,如果我关闭手机,然后重新打开,然后启动应用程序,我第一次启动应用程序时会出现同样的闪烁。
为什么会发生这种情况?!
其他人也遇到过这个问题吗?
干杯!
最佳答案
Apple 发布了有关此问题的更多信息:
Q: My OpenGL ES application flickers. Especially when running on iPhone 3GS, the flickering seems to happen every frame. How do I fix this problem?
A: By default, the contents of a renderbuffer are invalidated after it is presented to the screen (by calling -EAGLContext/presentRenderbuffer:). Your application must completely redraw the contents of the renderbuffer every time you draw a frame, otherwise you may observe flickering or other unexpected results.
You must provide a color to every pixel on the screen. At the beginning of your drawing code, it is a good idea to use glClear() to initialize the color buffer. A full-screen clear of each of your color, depth, and stencil buffers (if you're using them) at the start of a frame can also generally improve your application's performance.
If your application needs to preserve the drawable contents between frames, you can add the option kEAGLDrawablePropertyRetainedBacking = YES to your CAEAGLLayer object's drawableProperties property. Using this option requires additional memory and can reduce your application's performance.
关于iphone - 为什么我的 OpenGL ES iPhone 游戏在我第一次打开手机时会闪烁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/210225/