QOpenGLWidget auto-resize of viewpoint

  • I'm trying to develop an application that shows two QOpenGLWidgets side-by-side with a divider between them so that as the user slides the divider they can compare the two images contained in the Widget. An example of this is here:


    I want to do this in OpenGL because what I'm comparing is not really a static image, but a rendering of an image using fragment shaders to quickly recalculate lighting effect changes.

    Anyway, my obvious problem is that as a QOpenGLWidget is resized the object contained in it resizes as well. I tried to code my way out by changing the viewpoint as the window was resized to keep the image stationary on the screen. This kind of worked but I think because of rounding errors etc. the pixels "jitter" as the window resizes.

    Is there any way to keep pixels locked on the screen despite the size and position of the QOpenGLWidgets container? Is there fundamentally a better way to achieve what I want?

    Thanks for reading!

Log in to reply