Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-42107

QGraphicalEffects not compatible with OpenGL 4

    XMLWordPrintable

Details

    • c1c259ea76c4d8c94f6d96c3fd0bbbece25785bf

    Description

      On first glance at Qt 5.4.0 Beta, it looks like a lot of work has been done to be compatible with newer OpenGL contexts. Thanks.

      Any QML views that use the Graphical Effects 1.0 with a 4.1 Core context throw shader errors, and render solid purple instead of the intended effect. Switch back to 2.1 compatibility and the effects work as expected.

      Here is the shader error from a ColorOverlay:

      QOpenGLShader::compile(Fragment): ERROR: 0:1: '' : #version required and missing.
      ERROR: 0:5: 'varying' : syntax error syntax error

          • Problematic Fragment shader source code ***
            #define lowp
            #define mediump
            #define highp

      varying mediump vec2 qt_TexCoord0;
      uniform highp float qt_Opacity;
      uniform lowp sampler2D source;
      uniform highp vec4 color;
      void main()

      { highp vec4 pixelColor = texture2D(source, qt_TexCoord0); gl_FragColor = vec4(mix(pixelColor.rgb/max(pixelColor.a, 0.00390625), color.rgb/max(color.a, 0.00390625), color.a) * pixelColor.a, pixelColor.a) * qt_Opacity; }

      ***
      QQuickCustomMaterialShader: Shader compilation failed:
      "ERROR: 0:1: '' : #version required and missing.
      ERROR: 0:5: 'varying' : syntax error syntax error
      "

      To reproduce, here are the pertinent code snippets I am using to set the context and create a simple hover over effect in QML:

      QQuickView * m_pMainView = new QQuickView;

      QSurfaceFormat f;
      f.setProfile(QSurfaceFormat::CoreProfile);
      f.setVersion(4, 1);
      f.setSamples(16);
      f.setDepthBufferSize(24);
      m_pMainView->setSurfaceType(QSurface::OpenGLSurface);
      m_pMainView->setFormat(f);

      import QtQuick 2.3
      import QtQuick.Layouts 1.1
      import QtQuick.Controls 1.2
      import QtQuick.Controls.Styles 1.2
      import QtQuick.XmlListModel 2.0
      import QtGraphicalEffects 1.0

      Text {
      anchors.top: parent.top
      anchors.horizontalCenter: parent.horizontalCenter
      text: "Hello QML"

      ColorOverlay {
      id: activeDeleteButton
      opacity: 0
      anchors.fill: parent
      source: parent
      color: "red"
      MouseArea

      { anchors.fill: parent hoverEnabled: true onContainsMouseChanged: containsMouse ? activeDeleteButton.opacity = 1 : activeDeleteButton.opacity = 0 }

      }

      }

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-42107
          # Subject Branch Project Status CR V

          Activity

            People

              poikelin Joni Poikelin
              sterned Evan Stern
              Votes:
              9 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes