diff --git a/modules/gui/pymod/export_gl_canvas.cc b/modules/gui/pymod/export_gl_canvas.cc index 306f5fd670cc91543abf55db1f600375e98f735e..daf2eec4ef6fd6b482c5ec9ef4d685ac8f8b6d90 100644 --- a/modules/gui/pymod/export_gl_canvas.cc +++ b/modules/gui/pymod/export_gl_canvas.cc @@ -36,6 +36,7 @@ void export_GLCanvas() { .def("Show", &GLCanvas::show) .def("SetFormat", &WrapSetGLCanvasFormat) .def("SetDefaultFormat", &GLCanvas::SetDefaultFormat) + .def("SetStereoFormat", &GLCanvas::SetStereoFormat) .def("GetQObject",&get_py_qobject<GLCanvas>) .add_property("qobject", &get_py_qobject<GLCanvas>) ; diff --git a/modules/gui/src/gl_canvas.cc b/modules/gui/src/gl_canvas.cc index 41e192786143236ed6d3aefcafd0bc393bede569..c6f28c8a5d2a5593239fc4d23b3bc6664592073b 100644 --- a/modules/gui/src/gl_canvas.cc +++ b/modules/gui/src/gl_canvas.cc @@ -36,7 +36,10 @@ namespace ost { namespace gui { ost::gui::GLCanvas::GLCanvas(): QOpenGLWindow(), last_pos_(), show_beacon_(false), - bench_flag_(false) { } + bench_flag_(false) { + LOG_DEBUG("GLCanvas::registering with scene"); + gfx::Scene::Instance().Register(this); +} void GLCanvas::StatusMessage(const String& m) { // This Window can also be displayed without a full blown GostyApp. @@ -47,25 +50,31 @@ void GLCanvas::StatusMessage(const String& m) { } } -QSurfaceFormat GLCanvas::GetDefaultFormat() { +void GLCanvas::SetDefaultFormat() { QSurfaceFormat f = QSurfaceFormat::defaultFormat(); f.setRedBufferSize(8); f.setGreenBufferSize(8); f.setBlueBufferSize(8); f.setAlphaBufferSize(8); f.setDepthBufferSize(24); - return f; + this->setFormat(f); } -void GLCanvas::SetDefaultFormat() { - this->setFormat(GLCanvas::GetDefaultFormat()); +void GLCanvas::SetStereoFormat() { + QSurfaceFormat f = QSurfaceFormat::defaultFormat(); + f.setRedBufferSize(8); + f.setGreenBufferSize(8); + f.setBlueBufferSize(8); + // QOpenGLWindow seems to dislike alphabuffer in stereo rendering... + //f.setAlphaBufferSize(8); + f.setDepthBufferSize(24); + f.setStereo(true); + this->setFormat(f); } void GLCanvas::initializeGL() { LOG_DEBUG("GLCanvas::initializeGL()"); - gfx::Scene::Instance().InitGL(); - LOG_DEBUG("GLCanvas::registering with scene"); - gfx::Scene::Instance().Register(this); + gfx::Scene::Instance().InitGL(); } void GLCanvas::paintGL() { diff --git a/modules/gui/src/gl_canvas.hh b/modules/gui/src/gl_canvas.hh index 7ec714d18e04a7829854fa5e84fa0ba8c486b467..4d87a259aec6de8136a731b0ce95e79b1e79b27b 100644 --- a/modules/gui/src/gl_canvas.hh +++ b/modules/gui/src/gl_canvas.hh @@ -46,8 +46,8 @@ public: virtual bool HasMultisample() const {return format().samples() > 1;} // QSurfaceFormat for GL context setup - static QSurfaceFormat GetDefaultFormat(); void SetDefaultFormat(); + void SetStereoFormat(); // central point for sending input to the gfx layer void OnTransform(gfx::InputCommand, int indx, diff --git a/modules/gui/src/gl_win.cc b/modules/gui/src/gl_win.cc index d0fe7b5cb0a2d378dc9b13632663d50fbcafcedb..ee29b1f719014bbb291b0a2b617d9440fb758738 100644 --- a/modules/gui/src/gl_win.cc +++ b/modules/gui/src/gl_win.cc @@ -48,9 +48,7 @@ GLWin::GLWin(QWidget* p, bool try_stereo): Widget(NULL, p) { gl_canvas_ = new GLCanvas; if(try_stereo) { - QSurfaceFormat f = GLCanvas::GetDefaultFormat(); - f.setStereo(true); - gl_canvas_->setFormat(f); + gl_canvas_->SetStereoFormat(); } else{ gl_canvas_->SetDefaultFormat(); }