[Interest] OpenGL rendering in two separate windows in a Qt Quick application

Thomas Sevaldrud thomas at silentwings.no
Sun Mar 31 18:35:21 CEST 2024


After some digging I think that on MacOS QQuickWindows will share the actual QOpenGLContext, while on Windows there are separate instances of these for each window. If I’ve understood correctly  this is how it was done in Qt5 on Windows as well, which may explain why this worked before switching to Qt6.

So my question now is if there is any way to inject a common QOpenGLContext into two QQuickWindows or some other means to share the OpenGLContext. Simply enabling shared textures and buffers is not enough since I have a lot of VAOs and VBOs that are not shared with this kind of resource sharing. (I am basically rendering the same scene into two different windows with different camera angles).

Cheers,
Thomas



> On 4 Mar 2024, at 14:01, Thomas Sevaldrud <thomas at silentwings.no> wrote:
> 
> Hi, I have an application which has custom OpenGL rendering through a QQuickFramebufferObject and corresponding Renderer in a Qt Quick Window. 
> 
> Now, I need to open a second window which should use the same mechanism to render the scene from a different viewpoint. 
> 
> This works nicely on MacOS, but fails with a white window on Windows 11. I get a GL_INVALID_OPERATION_ERROR when trying to bind an FBO from the second window which was created in the first. I was thinking that there might be some differences in how MacOS and Windows handle context sharing, but I have tried setting a global shared context using the Qt::AA_ShareOpenGLContexts flag, and I have also tried creating my own share context. I have verified that the current context in each window has the same share context, but none of this seems to have any effect.
> 
> This is on Qt 6.6.2
> 
> Any ideas?
> 
> Cheers,
> Thomas



More information about the Interest mailing list