2

I'm having problem with OpenGL ES 1.0 rendering engine on my Nexus 7 - I'm trying to create frame buffer but it always return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES, 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.

keaukraine
  • 5,315
  • 29
  • 54
xc3s50an
  • 21
  • 3
  • It came to my mind that I might be initializing EGL wrong (I took the code from native-activity in Android NDK). – xc3s50an Jan 19 '13 at 01:53

1 Answers1

0

OpenGL ES (without extensions) requires that textures be a power-of-two in width and height. Check to see if you get a GL_INVALID_VALUE error after the glTexImage2D() call. If you get an error, then you might consider resizing your textures.

radical7
  • 8,957
  • 3
  • 24
  • 33