Using Shaders on a QGraphicsView

  • Hello,

    I need to show a 2D scene using different views (on different positions of the scene). I need also to apply a shader program to each of these views.
    My first thought was to use a QGraphicsScene and Views that shared the same scene. Much like the Chip example. So I created a subclass of QGLWidget that contained the shader program. An instance of this class is set as the Viewport of each QGraphicsView widgets I'm using.

    However, although my shader is compiling and linking correctly, nothing happens. I learned somewhere on these forums that I can't use regular painting on my QGLWidget subclass, as the QGraphics framework does its own painting and "bypasses" the QGLWidget painting, and therefore, the shaders wouldn't work.

    I cannot use QML because I really need two "windows" (views) to share the exact same scene. I cannot duplicate everything because most of the items are videos and that will compromise the performance.

    What is the best way to accomplish what I'm trying to do? Should I just go to plain OpenGL native painting and lose all the benefits of a Graphics Scene and the QGraphics Framework? Is there a way to enforce the shaders being used by QGraphicsView? Should I use QML and try to share the scene in any way?

    I appreciate each and every contribution. I'm completely lost here.

    Best regards,

Log in to reply

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