Framebuffer error (OpenGL SuperBible)

Hi, I have some problems with Listing 18.4 and 18.5 they are on the pages 619-621.

I can compile the project but when it starts I get that the function glCheckFramebufferStatusEXT doesn’t return GL_FRAMEBUFFER_COMPLETE_EXT. There are two framebuffers and I get the same error for both of them. I also get that glGetError isn’t equal to GL_NO_ERROR. The entire source code is copied from the books source code. Any ideas?

Here is the code:



// ==== GLOBAL ============================================

GLboolean doProcessing = GL_TRUE;  
GLuint framebufferID[2];

// ==== IN SETUP FUNCTION =================================

// Set up some renderbuffer state
    glGenRenderbuffersEXT(1, &renderbufferID);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbufferID);
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT32, fboWidth, fboHeight);

    glGenFramebuffersEXT(2, framebufferID);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID[0]);
    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, renderbufferID);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, renderTextureID[0], 0);

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID[1]);
    for (int i = 0; i < maxDrawBuffers; i++)
    {
        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, renderTextureID[i+1], 0);
    }
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

// ==== RENDER FUNCTION =====================================

if (doProcessing)
    {
        // draw the scene as pass 1 to an FBO
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID[0]);
        glViewport(0, 0, fboWidth, fboHeight);
        
        GLenum fboStatus = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
        if (fboStatus != GL_FRAMEBUFFER_COMPLETE_EXT)
        {
            fprintf(stderr, "FBO #1 Error!
");
        }
    }
    else
    {
        // just draw the scene to the window
        glViewport(0, 0, windowWidth, windowHeight);
    }

...

if (doProcessing)
    {
        GLint uniformLoc;
        int loopCount;

        // 2nd pass: Redraw from texture w/ fragment shader outputting to multiple targets
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID[1]);
}

...

if (useDrawBuffers)
        {
            // single shader will write to all 4 render textures simultaneously
            loopCount = 1;
            GLenum buf[4] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT};
            glDrawBuffers(maxDrawBuffers, buf);
        }
        else
        {
            // we need a separate shader pass for each render target
            loopCount = maxDrawBuffers;
        }

        while (loopCount--)
        {

...

GLenum fboStatus = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
            if (fboStatus != GL_FRAMEBUFFER_COMPLETE_EXT)
            {
                fprintf(stderr, "FBO #2 Error!
");
            }
}

...

// 3rd pass: Tile the multiple targets back to the window
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
        glViewport(0, 0, windowWidth, windowHeight);

...

if (glGetError() != GL_NO_ERROR)
        fprintf(stderr, "GL Error!
");


I can compile the project but when it starts I get that the function glCheckFramebufferStatusEXT doesn’t return GL_FRAMEBUFFER_COMPLETE_EXT.

OK, so what does it return? Every return value (except GL_FRAMEBUFFER_UNSUPPORTED) means that you have a problem with your code, and each return value represents a specific problem.

I checked the reutrn value, and I’m not sure what I get, I checked with every possible return value and it is none of them. But the GL_FRAMEBUFFER_UNDEFINED or GL_FRAMEBUFFER_UNDEFINED_EXT is undefined so I don’t know if that is the return value. I had to rename all other ending in _EXT and they were defined.

The return value I get as an int is: 36057

The page I linked you to covered the ARB/core version of FBOs, which has fewer limitations than the EXT version. The number in question, 0x8CD9, corresponds to GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT. This is returned when the dimensions of all of the attached buffers are not equal. This is a limitation of the EXT_FBOs only, not the ARB/core FBOs.