Reputation: 727
I am writing Android OepnGL program in native code.
The following code is called through jni, normal call, not inside any surface view.
When the glCheckFramebufferStatus() is called, the status is always 0.
GLuint textureA;
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &textureA);
glBindTexture(GL_TEXTURE_2D, textureA);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL);
GLuint fboA;
glGenFramebuffers(1, &fboA);
glBindFramebuffer(GL_FRAMEBUFFER, fboA);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
textureA, 0);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status == GL_FRAMEBUFFER_COMPLETE) {
LOGH("Single FBO setup successfully.");
} else {
LOGH("Problem in setup FBO texture: %d .", status);
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
Upvotes: 2
Views: 2359
Reputation: 727
Actually the problem not because of fbo operation but related to opengl context.
I am using opengl es by native code in Android, I need configure the opengl context by EGL library.
So I need prepare the context properly so I can create fbo.
Upvotes: 3