4

I'm new to OpenGL/GLES, I got Incomplete Missing Attachment error when generate framebuffer from EGLImageKHR with below code:

GLuint texture;
GLuint framebuffer;

EGLImageKHR image = eglCreateImageKHR(display,
                                      EGL_NO_CONTEXT,
                                      EGL_NATIVE_PIXMAP_KHR,
                                      (EGLClientBuffer)&pixmap,
                                      NULL);
assert(image != EGL_NO_IMAGE_KHR);

glGenTextures(1, &texture);
glGenTextures(1, &framebuffer);

glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureId);
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, image);

glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, 
                       GL_COLOR_ATTACHMENT0, 
                       GL_TEXTURE_EXTERNAL_OES, 
                       texture, 
                       0);
glCheckFramebufferStatus(GL_FRAMEBUFFER);
glBindFramebuffer(GL_FRAMEBUFFER, 0);

eglDestroyImageKHR(display,image);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);

I got GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT when using:

glFramebufferTexture2D(GL_FRAMEBUFFER, 
                       GL_COLOR_ATTACHMENT0, 
                       GL_TEXTURE_EXTERNAL_OES, 
                       texture, 
                       0);

and GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT when changing texture to GL_TEXTURE_2D:

glFramebufferTexture2D(GL_FRAMEBUFFER, 
                       GL_COLOR_ATTACHMENT0, 
                       GL_TEXTURE_2D, 
                       texture, 
                       0);

The image and texture is correct as I can display correctly. I don't know what I'm missing here.

KennyTan
  • 73
  • 1
  • 8
  • 1
    Thank you @Rabbid76, the problem is the system I'm working on using EGL extension to display UYVY image from camera directly, without color conversion so if I do as your suggestion it will drop the FPS from 30fps to around 15fps. That's why I have to stick with GL_TEXTURE_EXTERNAL_OES. – KennyTan Jan 13 '18 at 15:18
  • By the way, I also got Incomplete Attachment error even after `glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);`, is that normal? – KennyTan Jan 13 '18 at 15:25

1 Answers1

1

I just found the answer, as it is explained in Raspi forum: Can't render to render buffer

We have to use GL_TEXTURE_2D in this function:

glFramebufferTexture2D(GL_FRAMEBUFFER, 
                   GL_COLOR_ATTACHMENT0, 
                   GL_TEXTURE_2D, 
                   texture, 
                   0);

and have to create an empty texture GL_TEXTURE_2D to bind our framebuffer to that texture before rendering. GL_TEXTURE_EXTERNAL_OES and GL_TEXTURE_2D are different textures, cannot mix them together.

KennyTan
  • 73
  • 1
  • 8