Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Flickering FBO When Resizing Vertically



  • I get a flickering when QQuickFramebufferObject is vertically resized. Oddly enough, there is no flickering when resizing horontally. Here is the code:

    file main.qml:
    @import QtQuick 2.3
    import QtQuick.Controls 1.1
    import QtQuick.Layouts 1.1
    import Tools 1.0

    ApplicationWindow {
    width: 1000; height: 400
    visible: true
    toolBar: ToolBar {
    RowLayout {
    anchors.fill: parent
    ToolButton { id: button1; text: "button1"; anchors.left: parent.left }
    ToolButton { id: button2; text: "button2"; anchors.left: button1.right }
    }
    }
    RowLayout {
    anchors.fill: parent
    ColumnLayout {
    id: col1
    anchors.left: parent.left; Layout.fillHeight: true
    Button { id: button3; text: "button3"; width: 100 }
    Button { id: button4; text: "button4"; width: 100; anchors.top: button3.bottom }
    }
    Rectangle {
    anchors.left: col1.right; anchors.right: parent.right; Layout.fillHeight: true
    Renderer { anchors.fill: parent }
    }
    }
    }@

    file main.cpp:
    @#include <QApplication>
    #include <QQmlApplicationEngine>
    #include "fbo.h" // FBO

    int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    QQmlApplicationEngine engine;
    qmlRegisterType<FBO>("Tools", 1, 0, "Renderer");
    engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
    app.exec();
    return 0;
    }@

    file fbo.h:
    @#ifndef FBO_H
    #define FBO_H
    #include <QQuickFramebufferObject>
    #include "fborenderer.h" // FboRenderer

    class FBO : public QQuickFramebufferObject {
    Q_OBJECT
    public:
    Renderer* createRenderer() const { return new FboRenderer(); }
    };
    #endif // FBO_H@

    file fborenderer.h:
    @#ifndef FBORENDERER_H
    #define FBORENDERER_H
    #include <QQuickFramebufferObject> // QQuickFramebufferObject
    #include <QOpenGLFramebufferObject> // QOpenGLFramebufferObject

    class FboRenderer : public QQuickFramebufferObject::Renderer {
    public:
    void render();
    QOpenGLFramebufferObject* createFramebufferObject(const QSize &size);
    };
    #endif // FBORENDERER_H@

    file fborenderer.cpp:
    @#include "fborenderer.h"
    #include "fbo.h" // FBO

    void FboRenderer::render() {
    glClearColor(0.6, 0.1, 0.2, 1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    }
    QOpenGLFramebufferObject* FboRenderer::createFramebufferObject(const QSize& size) {
    QOpenGLFramebufferObjectFormat format;
    format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
    format.setSamples(16);
    return new QOpenGLFramebufferObject(size, format);
    }@

    As mentioned earlier, the minor flickering is there only when the scenegraph is resized vertically. I am running qt5.3.2(gcc 4.6.1, 64bit) on Linux Centos 6.5.

    As far as I can tell, changing the qml rendering does not fix this. I tried digging in the source files and I couldn't find any difference between how height change is handled versus how width change is.

    I also get same flickering for Scene Graph FBO examples (http://doc.qt.io/qt-5/qtquick-scenegraph-textureinthread-example.html and http://doc.qt.io/qt-5/qtquick-scenegraph-textureinsgnode-example.html .) I didn't notice any difference between resizing vertically and horizentally when using classic opengl with glwidget. It seems slower and flickering when resizing in both directions.


Log in to reply