Damian Damian - 1 year ago 130
Android Question

glGenFramebuffersOES fails in Android

I'm porting a game from iPhone to Android. I'm using NDK and OpenGLES 2.0.

I'm having a problem with the following code to create a framebuffer with a texture attached that I'll later use to render to it:

glGenFramebuffersOES(1, &glTextureFrameBuffer);
glBindFramebufferOES(GL_FRAMEBUFFER, glTextureFrameBuffer);

// attach renderbuffer

GLint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
cout << "Framebuffer completed" << endl;
} else {
cout << "Framebuffer error: " << status << endl;

// unbind frame buffer
glBindFramebufferOES(GL_FRAMEBUFFER, 0);

cout << "CREATED FRAMEBUFFER ID: " << glTextureFrameBuffer << endl;

This prints the following:

Framebuffer error: 0

And rendering to that texture does nothing, so something is failing and the id returned by glGenFramebuffersOES (4294967295) makes me think that the framebuffer is never generated.

The code is working perfectly on iOS.

Any idea what could be the problem?


I added error ckecking: I'm getting GL_INVALID_OPERATION after glFramebufferTexture2D.

But I'm also getting GL_INVALID_VALUE error after glGenFramebuffersOES. The strange thing is that on iphone I get that error too but everything works anyway.

I've read the OpenGLES docs and glGenFramebuffersOES sets GL_INVALID_VALUE error if the first parameter is negative, wich is not the case.


My bad, glGenFramebuffersOES is not setting any error, GL_INVALID_VALUE was being set somewhere before.

But still, glFramebufferTexture2D is setting GL_INVALID_OPERATION, and it also seems weird to me that the id returned by glGenFramebuffersOES is 4294967295.

Any idea?

Answer Source

Why are you using glBindFramebufferOES instead of glBindFramebuffer? OpenGL ES 2.0 has framebuffers in its core spec, not in OES extension (like OpenGL ES 1.0 have).

You are already using glFramebufferTexture2D function not glFramebufferTexture2DOES, right? So use the glGenFramebuffers function and also glGenFramebuffers.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download