Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Can't get ShaderEffectItem to work, any suggestions?
Qt 6.11 is out! See what's new in the release blog

Can't get ShaderEffectItem to work, any suggestions?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BigPrimate
    wrote on last edited by
    #1

    Hello -

    I am trying to use the ShaderEffectItem. I downloaded, built and installed the shader plug in, however when I attempt to run it I get the following error:

    ShaderEffectItem::paint - OpenGL not available

    My QML is as follows:

    @
    import QtQuick 1.0
    import QMLImage 1.0
    import Qt.labs.shaders 1.0

    Rectangle {
    width: 300
    height: 300
    color: "black"

    Text {
    id: textLabel
    text: "Hello World"
    anchors.centerIn: parent
    font.pixelSize: 32
    color: "white"

    }

    ShaderEffectItem {
    property variant source: ShaderEffectSource { sourceItem: textLabel; hideSource: true }
    property real wiggleAmount: 0.005
    anchors.fill: textLabel

    fragmentShader: "
    varying highp vec2 qt_TexCoord0;
    uniform sampler2D source;
    uniform highp float wiggleAmount;
    void main(void)
    {
    highp vec2 wiggledTexCoord = qt_TexCoord0;
    wiggledTexCoord.s += sin(4.0 * 3.141592653589 * wiggledTexCoord.t) * wiggleAmount;
    gl_FragColor = texture2D(source, wiggledTexCoord.st);
    }
    "
    }
    }
    @

    I am including the reference to opengl in my qmlapplicationviewer.pri file like so:

    QT += opengl

    I also include:

    #include <QtOpenGL>

    in my header file.

    Is there something else I have to do to get this to work?

    Looking forward to your response.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BigPrimate
      wrote on last edited by
      #2

      Found the answer myself, it turns out that in my main, I did not set the viewer viewport equal to a QGLWidget. The code below fixed by problem:
      @
      QGLFormat format = QGLFormat::defaultFormat();
      format.setSampleBuffers(false);
      format.setSwapInterval(1);
      QGLWidget* glWidget = new QGLWidget(format);
      glWidget->setAutoFillBackground(false);
      viewer.setViewport(glWidget);
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved