Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT while creating framebuffer with cubemap

  1. #1
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12

    GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT while creating framebuffer with cubemap

    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();

  2. #2
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12
    is anyone alive here!!!

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    491
    Quote Originally Posted by rakeshmalik91 View Post
    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.

  4. #4
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12
    i got my error
    i had used different width and height for cube map

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •