[Interest] Porting Qt5 OpenGL app to Qt6 - QQuickRenderTarget and OpenGL frame buffer object

Laszlo Agocs laszlo.agocs at qt.io
Wed May 8 17:41:50 CEST 2024


Hi,

Passing 0 as a renderbuffer object name is not going to work. Try using https://doc.qt.io/qt-6/qquickrendertarget.html#fromOpenGLTexture with the texture that is used as the color attachment of your OpenGL framebuffer object. (actually that FBO is not useful in Qt 6 as one will be created internally as needed)

Best regards,
Laszlo

________________________________
From: Interest <interest-bounces at qt-project.org> on behalf of Nuno Santos via Interest <interest at qt-project.org>
Sent: Tuesday, April 16, 2024 4:21 PM
To: interestqt-project. org <interest at qt-project.org>
Subject: [Interest] Porting Qt5 OpenGL app to Qt6 - QQuickRenderTarget and OpenGL frame buffer object

Hi,

I have an application that was heavily written on top of OpenGL. Right now I want to port it to Qt 6 with the minimum effort trying to stick to the OpenGL backend until I get the grip on the new things of Qt 6 Graphics API abstraction.

I used to do this in order to assign a target FBO to a QuickWindow:

_quickWindow->setRenderTarget(_fboRender);

This is no longer possible and it requires a QQuickRenderTarget to be created and I seem to have three options:

(since 6.2) QQuickRenderTarget  fromOpenGLRenderBuffer(uint renderbufferId, const QSize &pixelSize, int sampleCount = 1)
(since 6.4) QQuickRenderTarget  fromOpenGLTexture(uint textureId, uint format, const QSize &pixelSize, int sampleCount = 1)
QQuickRenderTarget      fromOpenGLTexture(uint textureId, const QSize &pixelSize, int sampleCount = 1)

I’m trying this:

_renderTarget = QQuickRenderTarget::fromOpenGLRenderBuffer(0, QSize(_renderResolution.width(), _renderResolution.height()));
_quickWindow->setRenderTarget(_renderTarget);

But nothing appears on the screen and I get a warning:

QQuickWindow: No render target (neither swapchain nor custom target was provided)

Can anyone tell me what am I failing here?

Any ideas suggestions are very welcome.

With my best regards,

Nuno
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240508/e0cb4674/attachment.htm>


More information about the Interest mailing list