Problems with creating frame buffer object usually with Intel drivers

Hi everyone,

Currently I’m investigating a problem where some clients of ours are getting a black screen. This happens only on Windows 7 with Intel drivers. It seem the cause of the problem is that instead of creating a frame buffer object with the requested dimensions the driver creates a frame buffer that is 0 by 0. No errors are reported back.

In the past I’ve also seen a problem where the frame buffer is returned as non-msaa while we request a msaa buffer. Again without any errors being reported.

I’m starting to wonder if I’m doing something wrong if there are huge errors with what I think is a very commonly used feature. Below is the code used to create the frame buffer object. Am I doing something wrong here? What can I improve in the below code? We are currently using OpenGL 3.2.

    
ERRORCODE Create(GLuint& frameBuffer,
                     GLuint& colorTexture,
                     bool useDepthTexture,
                     GLuint& depthTexture,
                     int width,
                     int height,
                     int msaaSamples)
    {
        char s[200];
#ifdef __APPLE__
        snprintf(s, 200, "Creating framebuffer, MSAA samples: %i, width %i, height %i", msaaSamples, width, height);
#else
        _snprintf_s(s, _countof(s), "Creating framebuffer, MSAA samples: %i, width %i, height %i", msaaSamples, width, height);
#endif
        Log::Write(s);

        // Create frame buffer
        VERIFY(glGenFramebuffers(1, &frameBuffer));

        // Make frame buffer active
        VERIFY(glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer));

        // Create buffer for storing colours
        VERIFY(glGenRenderbuffers(1, &colorTexture));

        // Make buffer active
        VERIFY(glBindRenderbuffer(GL_RENDERBUFFER, colorTexture));

        // Allocate memory for buffer
        if (msaaSamples == 1)
        {
            Log::Write("Creating colour renderbuffer storage, non-MSAA");
            VERIFY(glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, width, height));
        }
        else
        {
            Log::Write("Creating colour renderbuffer storage, MSAA");
            VERIFY(glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaaSamples, GL_RGBA8, width, height));
        }

        if (useDepthTexture)
        {
            // Create depth buffer
            VERIFY(glGenRenderbuffers(1, &depthTexture));

            // Activate buffer
            VERIFY(glBindRenderbuffer(GL_RENDERBUFFER, depthTexture));

            // Allocate memory for buffer, we use both depth and stencil
            if (msaaSamples == 1)
            {
                Log::Write("Creating depth stencil renderbuffer storage, non-MSAA");
                VERIFY(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height));
            }
            else
            {
                Log::Write("Creating depth stencil renderbuffer storage, MSAA");
                VERIFY(glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaaSamples, GL_DEPTH24_STENCIL8, width, height));
            }
        }

        // Attach colour buffer to frame buffer
        VERIFY(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorTexture));

        if (useDepthTexture)
        {
            // Attach depth buffer to frame buffer
            VERIFY(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthTexture));

            // Attach stencil buffer to frame buffer
            VERIFY(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthTexture));
        }

        ERRORCODE ec = EC_OK;

        GLenum status = VERIFY(glCheckFramebufferStatus(GL_FRAMEBUFFER));
        if (status != GL_FRAMEBUFFER_COMPLETE)
        {
            Log::Error("Framebuffer is not complete.", EC_FRAMEBUFFER_NOT_COMPLETE);
            ec = EC_FRAMEBUFFER_NOT_COMPLETE;
        }

        VERIFY(glBindFramebuffer(GL_FRAMEBUFFER, 0));

        return ec;
    }

I would appreciate any assistance.

Greets,

Floris

So I guess you don’t support Linux?

For MSVC, your _snprintf_s syntax looks wrong. 3rd arg should be _TRUNCATE. This actually compiled?

Not that this is the solution to all your problems, but any reason you’re not using GL_DEPTH_STENCIL_ATTACHMENT to attached the DEPTH_STENCIL renderbuffer?

No, we don’t :). Probably never will, because that’s not where our potential customers are.

Not only did it compile, it actually works :). There are two _snprintf_s functions (just found out).

Oversight on my part. I changed it, but it makes no difference. Tried it on a machine where I can reproduce the problem and I still get a black screen. Oddly, CodeXL is reporting that the buffer is unattached, but the framebuffer works on my own machine.

Thanks for your reply, Dark Photon.

Greets,

Floris

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.