我的 Nexus 7 上的 OpenGL ES 1.0 渲染引擎出现问题 - 我正在尝试创建帧缓冲区,但它总是返回GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES
,代码如下所示:
#ifdef __ANDROID__
glGenFramebuffersOES(1, &gameSurfaceFrameBuffer);
#else
glGenFramebuffers(1, &gameSurfaceFrameBuffer);
#endif
#ifdef __ANDROID__
glBindFramebufferOES(GL_FRAMEBUFFER_OES, gameSurfaceFrameBuffer);
#else
glBindFramebuffer(GL_FRAMEBUFFER, gameSurfaceFrameBuffer);
#endif
glGenTextures(1, &gameSurfaceTexture);
glBindTexture(GL_TEXTURE_2D, gameSurfaceTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4, 48 * 14, 48 * 12, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
#ifdef __ANDROID__
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, gameSurfaceTexture, 0);
#else
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gameSurfaceTexture, 0);
#endif
#ifdef __ANDROID__
GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
#else
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
#endif
#ifdef __ANDROID__
if(status != GL_FRAMEBUFFER_COMPLETE_OES){
#else
if(status != GL_FRAMEBUFFER_COMPLETE){
#endif
std::stringstream ss;
ss << "gameSurfaceFrameBuffer, status != GL_FRAMEBUFFER_COMPLETE ";
ss << "status = " << status;
throw ss.str();
}
}
如您所见,我有适用于 Android 和普通 OpenGL 的代码 - 该代码在 Windows 上运行良好,但在 Android 上它返回不完整的附件。