[osg-users] Loading problem, OpenVR integration

Lorenzo Valente oneiros.valente at gmail.com
Fri Nov 4 01:49:41 PDT 2016

Problem solved!  :D 
As guessed by Robert, the GL objects were not compiled properly.

In the old desktop-version of the software the compilation of the scene was performed by a osgUtil::GLObjectsVisitor created and launched in a subclass of osg::Camera::DrawCallback, which was assigned to the main camera as a "preDrawCallback" (I don't know if this is the right approach but it works and I don't want to mess up with the old system :) ).
It works fine but it relies on the renderer of a single main camera, the very camera that osgopenvrviewer deactivates (https://github.com/ChrisDenham/osgopenvrviewer/blob/master/src/openvrviewer.cpp#L61)! It means that in the VR environment that preDrawCallback was never called and the compilation was never performed.

The solution? I simply assigned the same callback also to every slave camera present in the view (in the osgopenvrviewer case these are two RTT cameras, one for the left eye and one for the right eye):

for (unsigned i = 0; i < view->getNumSlaves(); ++i)
   osgViewer::View::Slave& slave = view->getSlave(i);
   if (slave._camera.valid())

I used "setPostDrawCallback" because a preDrawCallback was apparently already assigned (replacing it resulted in a full deactivation of the rendering, black screen).
Is this wrong on any level? It works like a charm, no more frame drops :D

Thank you very much guys, your help pointed me to the right direction.
A special thanks to Robert!


Read this topic online here:

More information about the osg-users mailing list