When trying to attach texture buffer with half floating point to frame buffer it caused GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT , How I can solve this?
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_HALF_FLOAT, NULL);
GLuint depthbf;
glGenRenderbuffers(1, &depthbf);
glBindRenderbuffer(GL_RENDERBUFFER, depthbf);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
GLuint framebf;
glGenFramebuffers(1, &framebf);
glBindFramebuffer(GL_FRAMEBUFFER, framebf);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
glCheckFramebufferStatus(GL_FRAMEBUFFER); // GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthbf);
glCheckFramebufferStatus(GL_FRAMEBUFFER);//GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
I tested this sample on Mali T760 GPU (Galaxy S6).
when I change this line
with
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
there is no problem but I want to readPixels as floating Point.
glReadPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, data);
Your sampler type is wrong in the fragment shader if you are reading from an integer texture. Signed and unsigned integer formats have a specialist sampler type (isampler2D for signed integer and usampler2D for unsigned integer), so it's likely just returning black.
Also, you are setting up bilinear filtering (GL_LINEAR) for your texturing filter, which isn't allowed for integer formats. They are not filterable in the standard, and only support GL_NEAREST.
HTH,
Pete
Actually I changed sampler2D to isampler2D after I asked the question.
I removed texturing filter but the output still the same all channels = zeros except alpha channel =1
Any suggestions?