0

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

genpfault
  • 51,148
  • 11
  • 85
  • 139
DoNNNy
  • 3
  • 2
  • Are you checking for OpenGL errors with glGetError? – Dr. Snoopy Dec 02 '13 at 06:09
  • 1
    You're disabling both reads and writes. Why? – user1118321 Dec 02 '13 at 06:49
  • what OpenGL version are you working with? also, one more thing you might want to change: the internalformat parameter in glTexImage2D should be sized, i.e. GL_DEPTH_COMPONENT16 or another sized depth-renderable format ( http://www.opengl.org/wiki/Image_Format ) – gemse Dec 02 '13 at 10:02

1 Answers1

-1

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.

DoNNNy
  • 3
  • 2