[Interest] QOpenGLWindow or QOpenGLWidget if need to render to framebuffer?

Laszlo Agocs laszlo.agocs at qt.io
Wed Aug 2 08:27:42 CEST 2017


Hi,

It is always possible to render into an offscreen render target. You do not even need any window for that.

The typical pattern is:

QOpenGLContext ctx;
QSurfaceFormat fmt;
fmt.setDepthBufferSize(24);
…
ctx.setFormat(fmt);
if (!ctx.create()) panic();

QOffscreenSurface s;
s.setFormat(ctx.format());
s.create();

if (!ctx.makeCurrent(&s)) panic();

ctx.functions()->glBindFrameBuffer(…)
… // render

In the OVR case you presumably need to render into the texture retrieved from ovr_GetTextureSwapChainBufferGL. So you still need to create your own FBO with the depth attachment and whatnot, but the color attachment will be the provided texture.

If you already have a QOpenGLWindow, then the QOffscreenSurface is not necessary since you already have something that can be used with makeCurrent().

Best regards,
Laszlo

From: Interest [mailto:interest-bounces+laszlo.agocs=qt.io at qt-project.org] On Behalf Of Fan Kevin
Sent: onsdag 2. august 2017 02.41
To: interest at qt-project.org
Subject: [Interest] QOpenGLWindow or QOpenGLWidget if need to render to framebuffer?


Hi,
I was wondering between the difference between QOpenGLWindow and QOpenGLWidget.
I read that
"OpenGLWindow renders directly to the given window, while QOpenGLWidget renders to offscreen buffer that is then rendered to the widget"

I have to do some rendering to the framebuffer, as that is necessary for displaying in Oculus Rift.
However, it seems unable to do so in our software which is built upon QOpenGLWindow.
Is it possible to render to a framebuffer using QOpenGLWindow? or should I use QOpenGLWidget?
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170802/1fdebc85/attachment.html>


More information about the Interest mailing list