我目前正在为我的一个客户编写一个 Android 应用程序,该应用程序有一个带有 GLSurfaceView.Renderer 的 GLSurfaceView。
我的整个 OpenGL 东西都工作得很好(它基本上是另一个开发人员首先在 iOS 上编写的一个端口)。除了一件事。当视图被加载并因此 OpenGL 的东西被加载时,我的背景快速闪烁黑色,然后 OpenGL 开始正确渲染(使用我的背景)。所以我要做的是:
在 onSurfaceCreated 我从这个开始:
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
GLES20.glClearColor(0.9f + 0.1f * (21.0f / 255),
0.9f + 0.1f * (36.0f / 255),
0.9f + 0.1f * (31.0f / 255), 1.0f);
// Here goes my other stuff, if I comment all my other stuff out I still get the flash at startup
}
在我的 onDrawFrame 方法中,我这样做:
@Override
public void onDrawFrame(GL10 gl) {
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
// My stuff, again, if I comment all this stuff out I still get the flash...
}
因此,如果我删除除 onSurfaceCreated 中的 glClearColor(..) 之外的所有代码行,在设置实际背景颜色之前,我仍然会看到黑色闪烁。如果我只从我的代码中删除 glClearColor(..) (并因此保留所有其他 OpenGL 内容),那么所有内容都将呈现在黑色背景上。
我想看到的是我只是摆脱了黑色闪光,因此我的背景颜色在启动时被正确初始化......
有什么想法可以实现吗?
短剑