<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Blitting from the QOpenGLFramebuffer seems to downscale by 2]]></title><description><![CDATA[<p dir="auto">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:</p>
<pre><code>    /**************************************************************************\
    |* Save the offscreen image if it doesn't already exist
    \**************************************************************************/
 #ifdef DEBUG_BUFFERS
    QFileInfo check_file("/tmp/tst.png");
    if (!check_file.exists())
        _gl-&gt;dumpBuffer("/tmp/tst.png", 0);

    QFileInfo check_file2("/tmp/tst2.png");
    if (!check_file2.exists())
        {
        _gl-&gt;dumpBuffer("/tmp/tst2.png", 1);
        fprintf(stderr, "width: %d, height:%d\n",
            _gl-&gt;screenSize().width(),
            _gl-&gt;screenSize().height());
        }
#endif

    /**************************************************************************\
    |* And focus back onto the main backbuffer
    \**************************************************************************/
    _gl-&gt;focusOnscreen();

    /**************************************************************************\
    |* Blit the framebuffer to the screen
    \**************************************************************************/
    int w                           = _gl-&gt;screenSize().width();
    int h                           = _gl-&gt;screenSize().height();
    QRect trect                     = QRect(0,0,w,h);
    QRect srect                     = QRect(0,0,w,h);
    QOpenGLFramebufferObject *fbo   = _gl-&gt;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
                                              );

</code></pre>
<p dir="auto">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...</p>
<pre><code>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
</code></pre>
<p dir="auto">The problem is that when the rendering is done, all I see is a quarter of the screen...</p>
<p dir="auto"><img src="http://www.oobergeek.net/imgs/screen-image.png" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">As opposed to the frame buffer that the above code rendered:</p>
<p dir="auto"><img src="http://www.oobergeek.net/imgs/framebuffer-image.png" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">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 ?</p>
]]></description><link>https://forum.qt.io/topic/113806/blitting-from-the-qopenglframebuffer-seems-to-downscale-by-2</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 04:49:26 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/113806.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 18 Apr 2020 00:42:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Blitting from the QOpenGLFramebuffer seems to downscale by 2 on Sat, 18 Apr 2020 02:48:52 GMT]]></title><description><![CDATA[<p dir="auto">Not generally good form to reply to oneself, but it seems OpenGL isn't scaled on hiDpi screens, according to <a href="https://vicrucann.github.io/tutorials/osg-qt-high-dpi/" target="_blank" rel="noopener noreferrer nofollow ugc">this</a></p>
<p dir="auto">So calling QApplication::desktop()-&gt;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.</p>
<p dir="auto">Interestingly, the screen is <em>not</em> 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.</p>
]]></description><link>https://forum.qt.io/post/589413</link><guid isPermaLink="true">https://forum.qt.io/post/589413</guid><dc:creator><![CDATA[Spaced Cowboy]]></dc:creator><pubDate>Sat, 18 Apr 2020 02:48:52 GMT</pubDate></item></channel></rss>