PDA

View Full Version : GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT while creating framebuffer with cubemap



rakeshmalik91
08-09-2013, 03:41 AM
I am trying to create framebuffer with cubemap for environment-map, but it gives GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT error while attachment of the cubemap as color attachment.

void FrameBuffer::create(size_t width, size_t height) {
this->width=width;
this->height=height;

glGenFramebuffersEXT(1, &id);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
void FrameBuffer::attachDepthTexture() {
glGenTextures(1, &depthTexture);
glBindTexture(GL_TEXTURE_2D, depthTexture);

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);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthTexture, 0);

checkStatus();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
void FrameBuffer::attachColorTextureCube(GLuint i=0) {
i=clamp(i, 0, GL_MAX_COLOR_ATTACHMENTS_EXT-1);

glGenTextures(1, &colorTexture[i]);

glBindTexture(GL_TEXTURE_CUBE_MAP, colorTexture[i]);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

for (int face=0; face<6; face++)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+face, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, colorTexture[i], 0);

checkStatus(); //ERROR at this point
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}


function Call is done here:

reflectionFrameBuffer.create(Game::Settings::scree nWidth, Game::Settings::screenHeight);
reflectionFrameBuffer.attachDepthTexture();
reflectionFrameBuffer.attachColorTextureCube();

rakeshmalik91
08-09-2013, 05:59 AM
is anyone alive here!!!

GClements
08-09-2013, 06:01 PM
I am trying to create framebuffer with cubemap for environment-map, but it gives GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT error while attachment of the cubemap as color attachment.
Are you sure that's where the error occurs. Both attachDepthTexture() and attachColorTextureCube() call checkStatus(). As you call attachDepthTexture() first, I would expect the checkStatus() call there to fail as no colour buffer as been attached at that point.

Also, use CODE tags when posting code so that indentation is preserved.

rakeshmalik91
08-10-2013, 09:30 AM
i got my error
i had used different width and height for cube map