Skip to content
Snippets Groups Projects
Commit c4e2fa33 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

fix stereo rendering

- Directly Register GLCanvas to Scene at initialization
- Stereo Rendering (at least on our setup) fails when setting the alpha buffer
  -> disabled for stereo
parent ca734790
Branches
Tags
No related merge requests found
......@@ -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>)
;
......
......@@ -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() {
......
......@@ -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,
......
......@@ -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();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment