Important: Please read the Qt Code of Conduct -

Blitting from the QOpenGLFramebuffer seems to downscale by 2

  • Well, I mean, I'm sure it's not really - but I don't understand why it's looking that way. Here's the code in question:

        |* Save the offscreen image if it doesn't already exist
     #ifdef DEBUG_BUFFERS
        QFileInfo check_file("/tmp/tst.png");
        if (!check_file.exists())
            _gl->dumpBuffer("/tmp/tst.png", 0);
        QFileInfo check_file2("/tmp/tst2.png");
        if (!check_file2.exists())
            _gl->dumpBuffer("/tmp/tst2.png", 1);
            fprintf(stderr, "width: %d, height:%d\n",
        |* And focus back onto the main backbuffer
        |* Blit the framebuffer to the screen
        int w                           = _gl->screenSize().width();
        int h                           = _gl->screenSize().height();
        QRect trect                     = QRect(0,0,w,h);
        QRect srect                     = QRect(0,0,w,h);
        QOpenGLFramebufferObject *fbo   = _gl->fbo();
        GLbitfield what                 = GL_COLOR_BUFFER_BIT;
        GLenum filter                   = GL_NEAREST;
        int which                       = GL_COLOR_ATTACHMENT0;
        QOpenGLFramebufferObject::blitFramebuffer(0,        // Target = default
                                                  trect,    // Target rect
                                                  fbo,      // source
                                                  srect,    // source rect
                                                  what,     // what to copy
                                                  filter,   // how to copy
                                                  which,    // which buffer to copy
                                                  0         // No restore

    which prints out the width and height of the image in the offscreen buffer (1920x1080) and the program also prints out the dimensions of the window (1920x1080), so they ought to match...

    OpenGL version :  4.1 ATI-3.8.24 ( CoreProfile )  - renderToMultiple: yes
    Texture 'textures/map.ppm.gz' has id 3 [file type:5, tex type:8058
    Texture 'textures/fog.pgm.gz' has id 4 [file type:5, tex type:8058
    buffer width: 1920, height:1080
    window : 1920, 1080

    The problem is that when the rendering is done, all I see is a quarter of the screen...

    alt text

    As opposed to the frame buffer that the above code rendered:

    alt text

    Interestingly the size of the quarter-rendered image if I screenshot it, is 3838 x 2200. Am I running afoul of hi-dpi or something ?

  • Not generally good form to reply to oneself, but it seems OpenGL isn't scaled on hiDpi screens, according to this

    So calling QApplication::desktop()->devicePixelRatio() gives me a pixel ratio of 2, which means I guess I just set 'trect' in the code to have w and h scaled by 2.

    Interestingly, the screen is not scaled by 2, it's a 3200x1800 display on a native resolution of 5120x2880. The ultra-high DPI is just too much, but I want more than the standard half-resolution.

Log in to reply