Please nominate your Qt Champions for 2021!

OpenGLWidget not swapping?

  • I have an OpenGLWidget which (in paintGL) I'm clearing to red (as a test). It's set as the central widget in a QMainWindow. If I grabFramebuffer and dump than into a file I get a red image, as expected, however the OpenGLWidget appears black in the main window. This seems like a swapping issue but I read that with OpenGLWidget there is no need for a manual swap.

    (This of course is not a simple program. And it is on Mac, the code works fine on Windows. Qt version 5.8)

    Any ideas what can I do to troubleshoot this issue?

  • I switched to using QGLWidget and now it works. Any idea why it isn't working with QOpenGLWidget?

  • Maybe there is a problem of context when you generate or modify the fbo while using Mac, where the Qt implementation may change context in one OS and not in the other. Another possibility is that the format may not be supported in Mac. There are OpenGL methods (and those from Qt) to enable you to perform context management, maybe just enforcing that you are handling a specific context in your functions will do the job (the makeCurrent stuff)

Log in to reply