Horizontal-Interlaced-Stereo not working when integrated in Qt

classic Classic list List threaded Threaded
1 message Options
boy2melo boy2melo
Reply | Threaded
Open this post in threaded view
|

Horizontal-Interlaced-Stereo not working when integrated in Qt

Hi all,

I have a problem when trying to use the stereo mode HORIZONTAL_INTELACE with a viewer that is integrated into Qt utilizing the QOpenGLWidget: It doesn't work.

My integrated viewer class subclasses QOpenGLWidget as well as the osgViewer::Viewer.

In my initialization routine I create a graphic context like this:

  osg::DisplaySettings::instance()->setNumMultiSamples(DEFAULT_MULTISAMPLING);

  osg::ref_ptr<osg::GraphicsContext::Traits> pTraits = new osg::GraphicsContext::Traits;
  pTraits->x = 0;
  pTraits->y = 0;
  pTraits->width = DEFAULT_SCREEN_WIDTH;
  pTraits->height = DEFAULT_SCREEN_HEIGHT;
  pTraits->doubleBuffer = true;  
  pTraits->stencil = 8;

  mpGraphicsWindowEmbeddedContext = new osgViewer::GraphicsWindowEmbedded(pTraits.get());

I use this graphics content and set it to the render camera:

  mpRenderCamera->setGraphicsContext(mpGraphicsWindowEmbeddedContext);
  mpRenderCamera->setViewport(0, 0, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT);
  mpRenderCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
  mpRenderCamera->setClearColor(osg::Vec4(DEFAULT_BG_COLOR_R, DEFAULT_BG_COLOR_G,
                                                                   DEFAULT_BG_COLOR_B, DEFAULT_BG_COLOR_A));

For my QOpenGLWidget I have set my QSurfaceFormat like this:

  QSurfaceFormat format(QSurfaceFormat::defaultFormat());
  format.setSamples(DEFAULT_MULTISAMPLING);
  format.setStencilBufferSize(8);
  setFormat(format);

When I run my code I only see the image for the left eye without any interlacing by the image for the right eye.

I also tried the viewer from https://github.com/openscenegraph/osgQt but it gives me the same result.

I suppose it has something to to with the stencil buffer, but I don't know how to fix it. Can someone please help me?

Thanks in advance.