Shadow mapping. Framebuffer error 36060

357 views Asked by At

I am doing this from a tutorial and i have exactly the code from the tutorial. But for some reason is not working. So i debugged and i saw that it had a 36060 error also know as GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER as far as i know and i don't really understand why. I searched for answers and everybody said about glReadBuffer(GL_NONE); But even with that i get the same error.

    bool ShadowMapFBO::Init(unsigned int WindowWidth, unsigned int WindowHeight)
{
    // Create the FBO
    glGenFramebuffers(1, &m_fbo);    
    // Create the depth buffer
    glGenTextures(1, &m_shadowMap);
    glBindTexture(GL_TEXTURE_2D, m_shadowMap);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, WindowWidth, WindowHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(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);

    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);
    glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_shadowMap, 0);

    // Disable writes to the color buffer

    glDrawBuffer(GL_NONE);
    glReadBuffer(GL_NONE);
    GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

    if (Status != GL_FRAMEBUFFER_COMPLETE) {
        printf("FB error, status: 0x%x\n", Status);
        return false;
    }

    return true;
}

EDIT: seems like glReadBuffer doesn't work at all and I don't know why. I tried glGetError and i got no error

1

There are 1 answers

0
DoNNNy On

I solved the problem. Seems like I had to add glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo); Seems like if you don't need it if you have a nvidia video card. I had a intel integrated video card and that's why it didn't worked.