Transition from Qt 5.2.1 to 5.5.1 opengl drawing in application fails



  • I am currently working on upgrading from Qt 5.2.1 to 5.5.1. I was previously able to draw using opengl in qml. I am running Ubuntu 16.04. I based this heavily on the following example:

    http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html

    The major difference is that I draw pixels from a buffer, and wound up using QOpenGLPaintDevice and qpainter to get what I needed. This worked for me until moving up to version 5.5.1. I get no output on the cmdline when the draw fails. Nothing show up on the screen that I am specifically drawing and the application does not crash. I am able to test whether it is functioning if I can do the following:

    if (!m_painter) {
        initializeOpenGLFunctions();
        m_painter = new QOpenGLPaintDevice(DEFAULT_WIDTH,DEFAULT_HEIGHT);
    }
    res=false;
    QPainter painter;
    res = painter.begin(m_painter);
    
    if (res == true)
        fprintf(stderr,"Worked\n");
    else
        fprintf(stderr,"Failed\n");
    
    painter.fillRect(0,0,DEFAULT_WIDTH,DEFAULT_HEIGHT, QBrush(Qt::blue));
    painter.end();
    return;
    

    If that snippet draws a background color I can see then that the application appears to function properly and will draw the samples I hand it later.

    Any ideas on what has changed from 5.2.1 to 5.5.1 that would cause that implementation to fail? The opengl in qml example functions regardless the version, but it is using a shader program.

    Thanks


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Any reason for using such an old version of Qt ? Can you check with a more recent version ? Current is 5.10.1 and LTS is 5.9.4.



  • @SGaist We were trying to stick with the latest version available from the Ubuntu repos. We just had an opportunity to move up from Ubuntu 14.04 to 16.04. Hence the qt version change. Seeing as we are making several changes, a wholesale change in the qt version will not be the biggest problem. I will pull down the LTS and and give that a shot and report back. Thank you for the input.



  • Version 5.9.4 did not make a difference in the behavior.


  • Lifetime Qt Champion

    Can you setup a minimal sample application that reproduce that behaviour ?

    You should also take a look at the bug report system to see if you find anything related.



  • Hmmm what you're seeing vaguely reminds me of experience developing&maintaining an app through from Qt4.x's "declarative" QML (with some custom OpenGL) through various Qt5.x versions up to and including the latest QtQuick. Initially with early versions in the Qt5.x series I used much the same approach as that example you link... but then around Qt5.3/5.4 or so I found it ran into problems (I forget the exact details and version) and ended up fixing them by migrating to using a QQuickFramebufferObject and QQuickFramebufferObject::Renderer instead.

    With hindsight... I'm guessing QSG was getting some scene-graph optimisations around then, and things like batching might have been changing the render order and leaving the OpenGL state in something different to what I had been in a previous version. Moving to a QQuickFramebufferObject might have separated things out better somehow, although it might not have actually been necessary if I'd known which bit of state needed prodding (but in the end it was a good change because it let us do much more fancy things with the OpenGL-rendered custom elements).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.