On Thursday, 11 September 2025 12:28:52 Central European Summer Time Mike Krus
via Interest wrote:
> Hi
>
> I’m porting a project from Qt5/OpenGL SceneGraph code to new Qt6/RHI
>
> I have a custom item with a scene graph which creates a custom shader and a
> custom texture from some application data (not an image).
>
> In Qt5, I have Texture class derived from QSGTexture which create the
> underlying OpenGL buffers for the textures and handles to data, binding,
> etc.
>
> In Qt6, the same classes exists but the custom Texture class needs to create
> RHI based texture objects, with the appropriate format, copy the data into
> it, etc. But I have not been able to find some relevant code to do that.
> All the code I found in QtDeclarative itself either use
> QQuickWindow::createTextureFromImage() or a QSGTextureProvider.
>
> There some example which create custom RHI textures, but not in the context
> of the scene graph (using RHI directly in QQuickRHIItem for example).
>
> Any ideas how this can be done?
>
The way we do in Qt WebEngine now, is using QNativeInterface. For instance
from OpenGL texture
QNativeInterface::QSGOpenGLTexture::fromNative(texture, win, size, texOpts);
or from Metal texture
QNativeInterface::QSGMetalTexture::fromNative(texture, win, size, texOpts);
or from Vulkan texture
QNativeInterface::QSGVulkanTexture::fromNative(importedImage,
importedImageCreateInfo.initialLayout, win, size, texOpts);
Best regards
Allan
_______________________________________________
Interest mailing list
[email protected]
https://lists.qt-project.org/listinfo/interest