Using QML Items as texture for custom QSGGeometry QML QQuickItem
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.
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).
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?
It's a little bit simpler but very similar, "here":http://qt-project.org/forums/viewthread/28265/
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.
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
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.