Stereo QOpenGLWidget surface
-
Hi,
I'm attempting to create a quad buffered, stereo OpenGL context to use with QOpenGLWidget, but I'm having difficulty getting things to work as expected.
I'm setting the Default QSurfaceFormat to what I want, prior to calling QApplication, but inside my QOpenGLWidget derived class's paintGL() method, my surface is not reporting as stereo, and there doesn't appear to be any warning or error to tell me why.
int main(int argc, char * argv[]) { QSurfaceFormat format; format.setOptions(QSurfaceFormat::StereoBuffers); format.setProfile(QSurfaceFormat::CoreProfile); format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); format.setStereo(true); QSurfaceFormat::setDefaultFormat(format); QApplication app(argc, argv); ViewportWidget viewport(nullptr); viewport.show(); return app.exec(); } void ViewportWidget::paintGL() { std::cout << "Stereo: " << (format().stereo() ? "true" : "false") << std::endl; GLboolean is_stereo = GL_TRUE; glGetBooleanv(GL_STEREO, &is_stereo); std::cout << "GL_STEREO: " << (is_stereo == GL_TRUE ? "true" : "false") << std::endl; }
Outputs:
Stereo: false
GL_STEREO: falseI know stereo is working on my machine, as glxgears -stereo works as expected.
Any ideas what I might be doing wrong?
I'm running Qt opensource 5.8 on Linux, with a NVidia Quadro 4000 GFX card and proprietary drivers.
-
I worked it out. It was because the QOpenGLWidget uses an FBO under the hood, and so all calls get redirected to it. I guess Qt doesn't then do any special mapping of FBO color attachments to display buffers to allow for GL_BACK_LEFT and friends to continue working seamlessly.
Solution was to use a QOpenGLWindow instead, and I'm hoping that QWidget::createWindowContainer() will let me continue to work as expected.