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. [SOLVED] Using a vtk renderer in QtQuick
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Using a vtk renderer in QtQuick

Scheduled Pinned Locked Moved QML and Qt Quick
30 Posts 7 Posters 23.8k 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.
  • M Offline
    M Offline
    Martell Malone
    wrote on 13 Feb 2013, 17:14 last edited by
    #16

    Thansk for that z.emb

    I was working basing my code from qt3d before which is why I couldn't get it to work
    http://qt.gitorious.net/qt-labs/qt3d/blobs/83fd6411a16f09b81252d4a4398a1968451754c9/src/imports/threed/viewportfbonode_sg.cpp

    Seems you found the solution ;)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Martell Malone
      wrote on 13 Feb 2013, 17:51 last edited by
      #17

      glPopAttrib and glPushAttrib are invalid functions?

      You can do beginNativePainting within QPainter to access these functions but I'm guessing thats not what you did.

      Im on qt 5.0.1 ANGLE GLES version

      What header did you include?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Martell Malone
        wrote on 14 Feb 2013, 03:26 last edited by
        #18

        I've made more progress on getting it working on GLES systems.
        My window flickers for a frame and then goes gray.

        Also for that frame the scene is upside down and a texture is missing.

        The last two things that I wish to ask

        1. I noticed
          setFbo isn't called anywhere?

        and also I have two size methods setRect and setSize

        @void ColorNode::setSize(const QSize size)
        {
        if (size == m_size) return;

        m_size = size;
        //m_fbo = NULL;
        //m_texture = NULL;
        
        QSGGeometry::updateTexturedRectGeometry(&m_geometry,
                                                    QRectF(0, 0, m_size.width(), m_size.height()),
                                                    QRectF(0, 0, 1, 1));
        
        markDirty(DirtyGeometry);
        

        }

        void ColorNode::setRect(const QRectF rect)
        {
        if (m_rect == rect) return

            markDirty(DirtyGeometry);
            m_rect = rect;
        

        }@

        I'm guessing yous implementation is different?
        Could I get a quick look :)

        I think I'm really close

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          z.emb
          wrote on 14 Feb 2013, 08:51 last edited by
          #19

          Actually, I posted almost the whole implementation already, but here you go: "Node":http://pastebin.com/8CgheNzm . The implementation of the texture and the item are already posted.

          bq. I noticed setFbo isn’t called anywhere?

          You may have noticed that I pass the FBO to the constructor of the texture ;-)

          bq. What header did you include?

          I compiled Qt 5.0.0 with ANGLE deactivated and the -opengl desktop flag, because I use VTK which also uses the native OpenGL system.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Martell Malone
            wrote on 14 Feb 2013, 11:57 last edited by
            #20

            I need to set the geometry in my setsize or I get nothing in the window.

            @
            QSGFboTexture::QSGFboTexture(QGLFramebufferObject* fbo)
            :QSGTexture()
            {
            m_fbo = fbo;

            // setFbo(fbo);
            if (m_fbo != NULL)
            firstTimeBound = true;

            }
            @

            same as setFbo ;-)

            The problem is that on ANGLE we are using a GLES emulator not OpenGL.
            Those two functions don't exsist.

            What happens to your window when you dont call the push and pop?

            @void ColorNode::preprocess()
            {
            if(m_fbo == NULL) return; //will happen a few times

            QOpenGLContext::currentContext()->functions()->glUseProgram(0);
            m_fbo->bind();
            

            CCDirector::sharedDirector()->mainLoop();

            m_fbo->release();
            

            m_fbo->toImage().save("name.png","png");

            }@

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              z.emb
              wrote on 14 Feb 2013, 13:04 last edited by
              #21

              Its not working without the push and pop (nothing is rendered, only the background). Unfortunatelly I cannot tell you why, I'm no OpenGL expert.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Martell Malone
                wrote on 18 Feb 2013, 16:01 last edited by
                #22

                I think I understand why.
                The only problem is GLES doest support those functions so how do we get around them?

                Maybe I should make a new thread to this issue?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Martell Malone
                  wrote on 5 Mar 2013, 01:48 last edited by
                  #23

                  I found a new way of solving this problem.

                  It Involves setting up a separate opengl context and switching between the two before and after binding and releasing the fbo.

                  Any idea how to draw correctly for a y inverted fbo.
                  On qquickpainteditem we can set it to flip but not for the qsgtexture :/

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    z.emb
                    wrote on 5 Mar 2013, 08:41 last edited by
                    #24

                    Hey, thanks for your reply. Can you provide some code how you do that?
                    In my case, it also seems to be the cleanest way to do the same thing and I wan't to try that. :-)

                    For the flipping problem I would naivly just scale (glScale) the y-Axis with -1. But as I mentioned, I'm no OpenGL expert.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Martell Malone
                      wrote on 11 Mar 2013, 09:51 last edited by
                      #25

                      Hey z.emb

                      I used what was on this thread.

                      http://qt-project.org/forums/viewthread/25268/

                      I just changed this line for the flip y.

                      QSGGeometry::updateTexturedRectGeometry(&m_geometry,
                      QRectF(0, 0, m_size.width(), m_size.height()),
                      QRectF(0, 0, 1, 1));

                      to

                      QSGGeometry::updateTexturedRectGeometry(&m_geometry,
                      QRectF(0, 0, m_size.width(), m_size.height()),
                      QRectF(0, 1, 1, -1));//0011 = old y fliped

                      1 Reply Last reply
                      0
                      • Z Offline
                        Z Offline
                        z.emb
                        wrote on 11 Mar 2013, 09:55 last edited by
                        #26

                        Can you give me some code how you switched the GL-context?

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          Martell Malone
                          wrote on 28 May 2013, 16:29 last edited by
                          #27

                          Hey Guys,

                          Apologies about not replying.
                          I didn't realize I got a response.

                          I swapped the context at the very beginning by using the code in this thread

                          http://qt-project.org/forums/viewthread/25268/

                          Hope that helps Ricky, just got your pm.

                          Many Thanks
                          Martell

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            rlonka
                            wrote on 2 Jan 2014, 13:44 last edited by
                            #28

                            Hi,

                            I still did not get it.
                            Could you, please, anyone post a full example about rendering vtk to qtquick?
                            I was trying to understand the discussion but I did not get through...

                            Best regards,

                            radek

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              rpetryniak
                              wrote on 2 Feb 2014, 12:13 last edited by
                              #29

                              Hey, I join to this request. Even the simplest example would be helpful.

                              Regards,
                              rafal

                              1 Reply Last reply
                              0
                              • N Offline
                                N Offline
                                niker91
                                wrote on 11 Jul 2018, 17:07 last edited by
                                #30

                                I have created a repository with code that integrates VTK with Qt QuickControls 2, tested with VTK 8 and Qt 5.9. You can find the code here https://github.com/nicanor-romero/QtVtk with building instructions in the README. Also a brief article about it,
                                https://blog.bq.com/es/integrating-qtquickcontrols-2-with-vtk/

                                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