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. QQuickFramebufferObject is flipped on Y axis in QML
Forum Updated to NodeBB v4.3 + New Features

QQuickFramebufferObject is flipped on Y axis in QML

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 3.5k 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
    mecanix
    wrote on last edited by
    #1

    Hello,

    This is my first post on qt-project. I have created a new QML project, and I use a custom QML item to integrate raw OpenGL.

    If I take a screenshot using @framebufferObject()->toImage().save("a.png");@ in the QQuickFramebufferObject::Renderer then the surface is correctly renderer, but the QML surface is flipped on Y-axis.

    To fix that, I need to scale my matrix by -1 on Y-axis, but now my screenshot is flipped. I think that the flip come from QML vs OpenGL coordinates. Can someone give me a the QML to render properly instead of scaling my matrix ?

    Thank you in advance !!
    Victor

    1 Reply Last reply
    0
    • slettaS Offline
      slettaS Offline
      sletta
      wrote on last edited by
      #2

      We should allow flipping the y coordinate more easily in the QQuickFramebufferObject class, see https://bugreports.qt-project.org/browse/QTBUG-41073

      A QML way to do the same would be to set a transform: Scale { xScale: 1; yScale: -1; origin.x: width / 2; origin.y: height / 2; }. Basically flip the way it is rendered to screen. Be aware of that this will also flip input events though, so if you have a MouseArea or similar you will have to place it besides the FBO or take the inversion into account.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mecanix
        wrote on last edited by
        #3

        Thank you for the answer. For now, I will waiting for a more easily way from QQuickFramebufferObject :)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dasRicardo
          wrote on last edited by
          #4

          Hmm i use QQuickFramebufferObject to create a dynamic texture and render this texture with QSGSimpleTextureNode. To correct the output of the backbuffer i do this:
          @
          setTextureCoordinatesTransform(QSGSimpleTextureNode::MirrorVertically);
          @
          Take a look at "this":http://qt-project.org/doc/qt-5/qsgsimpletexturenode.html#setTextureCoordinatesTransform

          **Sorry for my english :)

          PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mecanix
            wrote on last edited by
            #5

            [quote author="dasRicardo" date="1412586609"]Hmm i use QQuickFramebufferObject to create a dynamic texture and render this texture with QSGSimpleTextureNode. To correct the output of the backbuffer i do this: [...]
            [/quote]

            Sounds good, but I don't know yet how to access the raw scene graph, and this is why I think we need an easy way :)

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dasRicardo
              wrote on last edited by
              #6

              Hmmm take a look at "this":http://qt-project.org/doc/qt-5/qtquick-scenegraph-customgeometry-example.html. But use QSGSimpleTextureNode instead of QSGGeometryNode. A simple rendering can look like this.
              @
              QSGNode *YourClass::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) {
              QSGNode *node = oldNode;
              if (!node) {
              node = new QSGNode();
              }
              if (this->_fbo == NULL) {
              this->_fbo = new QGLFramebufferObject(QSize(this->boundingRect().width(), this->boundingRect().height()));
              QSGTexture *m_texture = this->window()->createTextureFromId(this->_fbo->texture(),QSize(this->boundingRect().width(), this->boundingRect().height()), QQuickWindow::TextureHasAlphaChannel);
              QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode();
              textureNode->setTexture(m_texture);
              textureNode->setTextureCoordinatesTransform(QSGSimpleTextureNode::MirrorVertically);
              textureNode->setRect(this->boundingRect());
              textureNode->setFiltering(QSGTexture::Linear);
              node->appendChildNode(textureNode);
              }

              return node;
              }
              @
              Is an example but should show how to render a backbuffer with scenegraph

              **Sorry for my english :)

              PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

              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