AnsweredAssumed Answered

[OpenGL ES 3.0]  Frame Buffer Object with Texture format set to GL_LUMINANCE issues

Question asked by Anthony Gonin on Oct 14, 2016
Latest reply on Oct 18, 2016 by Anthony Gonin

Hi all,


I'm working with OpenGL ES 3.0 on the imx6q sabreSD.


Here is my problem : I would like to render 2 images offscreen (which come from previous rendering) and then blend them together with a special algorithm. My first image/texture is RGB and the second one is in grayscale, so I only got the luminance.


I think the best way to achieve my goal is to use Frame Buffer Object. So I create one FBO for the first image, then I associate to that FBO a new texture which will received the rendering output. The texture's format is GL_RGB and it works fine, my first FBO contains the rendering in its texture.
Then I do the same with the second image which its format is GL_LUMINANCE. But in the draw function, when I bind to this FrameBuffer and check the Status I got the error GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT. And if I change the texture to RGB it works.


But for the blending I need to access to the luminance and not the rgb component of my image.


Do you have any solutions?


Here is my code :
1 - Creation of the Frame Buffer Object and texture

Code :
glGenFramebuffers(1, &m_uiFrameBufferObject); glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject);   glGenTextures(1, &m_uiTextureId[1]); glBindTexture(GL_TEXTURE_2D, m_uiTextureId[1]);   glTexImage2D(     GL_TEXTURE_2D, 0, GL_LUMINANCE, 1280, 960,                          0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);   glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_uiTextureId[1], 0); glDrawBuffers(1, attachments);    //GL_COLOR_ATTACHMENT0

Then in the draw function :



Code :
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject);   if( glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT ) {      // I go there }   glViewport(0, 0, 1280, 960); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);   glUseProgram(m_ProgCamera.GetHandle());   glVertexAttribPointer(0, 3, GL_FLOAT, 0, 0, vVertices); glEnableVertexAttribArray(0);   // Bind the color attributes glVertexAttribPointer(1, 3, GL_FLOAT, 0, 0, g_vertexColors); glEnableVertexAttribArray(1);   glVertexAttribPointer(2, 2, GL_FLOAT, 0, 0, g_vertexTexCoords); glEnableVertexAttribArray(2); // Select Our Texture glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_textureCamera.GetHandle());   glDrawArrays( GL_TRIANGLES, 0, 6 );   // Cleanup glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2);

Thanks for your time.