Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Draw a QWidget into a FBO or a OpenGL texture

Draw a QWidget into a FBO or a OpenGL texture

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 4.4k Views 2 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi,

    I want to make the rendering of my QWidget into a OpenGL texture. Currently I use the function grab(), convert the result to QImage and get the constData to send it on VRAM. The question is : is it possible to render the QWidget directly on a FBO or glTexture ?

    I looking on setRedirected() but this function seem deprecied.

    Best regards,
    Robin

    T 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Me again. Still not super with opengl but I wonder if this is something like it
      https://github.com/belab/widgetTo3dTexture

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thanks again ^^

        the code below

        renderTarget_ = QPixmap(width(), height());
        renderTarget_.fill(QColor(0, 0, 0, 0));
        QPainter painter(&renderTarget_);
        render(&painter);
        

        is speeder than this code : widget->grab();

        1 Reply Last reply
        1
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ok. seems more direct but still not directly on gl texture but I guess its as close as you get :)

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @Robinsondesbois Hi! May I ask what this is good for? Maybe there is a better way.

            1 Reply Last reply
            0
            • ? A Former User

              Hi,

              I want to make the rendering of my QWidget into a OpenGL texture. Currently I use the function grab(), convert the result to QImage and get the constData to send it on VRAM. The question is : is it possible to render the QWidget directly on a FBO or glTexture ?

              I looking on setRedirected() but this function seem deprecied.

              Best regards,
              Robin

              T Offline
              T Offline
              t3685
              wrote on last edited by
              #6

              @Robinsondesbois

              Although this does not work completely for us, it gave us a good starting point:

              https://dangelog.wordpress.com/2013/02/10/using-fbos-instead-of-pbuffers-in-qt-5-2/

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                I need to draw a QMainWindow into an OpenGL texture. The aim is, I want a Qt GUI into a OpenGL scene.
                I think the t3685's method is too slow. Too much swap OpenGL context (one per widget I suppose).

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  If you can switch from QWidgets to QtQuick then there might be a high performance solution: QtQuick scenes are rendered with OpenGL and one can set the render target of a QQuickWindow to an FBO of your choice. You could then use this FBO in your own OpenGL scene. This should be pretty fast as the rendered image of your "3D GUI" would never leave the graphics card's memory.

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    You're rigth. It seem a good way to solve my problem.

                    Thanks :)

                    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