I’m having problem with OpenGL ES 1.x rendering engine on my Nexus 7 - I’m trying to create frame buffer but it always return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES no matter what, the code is as shown below:
#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();
}
}
As you can see I have the code for both Android and normal OpenGL - the code works on Windows just fine but on Android it returns incomplete attachment.
I took the code to create EGL surface from native-activity sample, maybe it’s something about that which doesn’t allow me to create the buffer?