iphone - 为什么我的 OpenGL ES iPhone 游戏在我第一次打开手机时会闪烁?

标签 iphone opengl-es

我使用 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/

相关文章:

ios - 在iPhone中仅使用G.729编解码器进行VOIP调用

iphone - 注释标注字幕可以是启动 Safari 的链接吗?

iphone - AirPlay 支持、MPMoviePlayerController 和 MPVolumeView 关系

android 从 GL_TEXTURE_EXTERNAL_OES 读取像素

java - OpenGL 在 Android 2.3.7(CyanogenMod-7) 上绑定(bind)空白纹理,而在其他 Android 版本上绑定(bind)实际图像

iphone - 从幻灯片 View 加载 UIWebView

iphone - 调整 UIView 的大小 - 扩展顶部

Android SurfaceView 与 GLSurfaceView 的壁纸风格背景

android - ExceptionInInitializerError 异常

math - 尝试理解 WebGL 中透视矩阵背后的数学原理