[Interest] Render QQuickRenderControl render target texture into a QuickItem in the visible QQuickWindow

Nuno Santos nuno.santos at imaginando.pt
Tue Jun 29 17:27:13 CEST 2021


Hi,

I’m trying to make a offscreen renderer for a quick scene and then display it’s output in the main and visible QQuickWindow scene.

The reason I’m trying to achieve this is because I need to intercept the frames to be able to send them to other programs or encode as a video file.

I’ve based myself on the rendercontrol example and I have a working offscreen renderer. Now, what I’m trying to do is to paint the result of the offscreen renderer into the main QQuickWindow.

What I’m doing is creating a new QQuickItem that paints a texture. When I declare this item in qml, I register it on the render control. Render control has it’s own render timing. Whenever render control paints, I tell the registered quick item to paint with the fbo texture.

The problem is that the only thing that is painted is black. I’m pretty sure the quick item is paint texture correctly because it works with images:

// render method

…

if (_renderView)
{
    _renderView->setImage(_fbo->toImage()); // this works
    _renderView->setTexture(_quickWindow->createTextureFromId(_fbo->texture(), _size)); // this doesn’t work - only black is painted
}

… 

I wonder if I’m stumbling on synchronisation issues. Maybe when its time for the main window to paint again, that texture is not valid anymore. 

Performance is a key factor in this architecture. I need the fastest solution possible and it doesn’t seem that creating a QImage from a texture and then convert it to QSGTexture is the most performant solution possible.

Has anyone been here before? 

Any advise on how to overcome this problem?

Thanks!

Best regards,

Nuno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210629/1b7a678a/attachment.html>


More information about the Interest mailing list