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. Using QML Items as texture for custom QSGGeometry QML QQuickItem
Forum Updated to NodeBB v4.3 + New Features

Using QML Items as texture for custom QSGGeometry QML QQuickItem

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 3.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.
  • M Offline
    M Offline
    MikeTrahearn
    wrote on last edited by
    #1

    Hi,

    I am looking to use a QML item and use its content to render onto a non-regular polygon created with a QQuickItem which creates its own QSGGeometry and texture coordinates.

    1. So far, I can create the geometry and texture coordinates in a custom QQuickItem which can be instantiated in QML. (Although it crashes on draw because no texture is set on the QSGTextureMaterial).

    2. I can also use a ShaderEffectSource in QML to grab a QML Item tree as a texture.

    What I need to be able to do is to push the grabbed texture onto the custom QQuickItem geometry and hide the original Item tree in order to see a visual "warped" version of the original Item tree.

    I tried using the QML Item layer to push the texture onto, but this only results in the texture showing in a rectangle form using basic boundary rect according to the target Item. What I want to do is to have the texture respect the custom geometry and texture coordinates (linking the two bits from 1 and 2 above).

    Has anyone succeeded in doing this?

    Thanks,

    Mike

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

      It's a little bit simpler but very similar, "here":http://qt-project.org/forums/viewthread/28265/

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

        Hi belab,
        Thanks for the suggestion however I really need to do is to get the image of a rendered QML Item (and its subtree) e.g. using a ShaderEffectSource and then using that image as a texture to use on another QQuickItem derived class which has custom geometry.
        As I said, I can grab the texture and I have the custom item. I just can't create the texture in that custom item yet because I don't know how to assign it from the ShaderEffectSource from QML.
        Any suggestions appreciated.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lemourin
          wrote on last edited by
          #4

          shaderEffectSource->textureProvider()->texture() called in QQuickItem::updatePaintNode will extract the QSGTexture* for you assuming that shaderEffectSource is of qml type ShaderEffectSource. pity there is no c++-only api for doing this

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

            Thanks lemourin,

            Eventually I got it working a while back, but it was not a nice experience writing lots of nasty c++ to get around the lack of public API for doing this and has been captured by the following bug.

            https://bugreports.qt-project.org/browse/QTBUG-31989

            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