FlightGear with quad buffered stereo
With my upcoming new headtracking driver for the vusix vr920 hmd it is likely that I manage to get the famous flight simulator FlightGear to work with it. This led me again to the problem that FlightGear does not work in quad buffered stereo, as I described in my comment to FlightGEAR 2.0.0 on GENTOO.
One expects to enable stereoscopic mode in FlightGear starting it with the following line:
export OSG_STEREO_MODE=QUAD_BUFFER;export OSG_STEREO=ON; fgfs
When starting flightgear this way, one gets the following console output and no stereoscopic view:
Warning: detected OpenGL error ‘invalid operation’ after RenderBin::draw(,)
Getting FlightGear to work with quad-buffered stereo
Doing some code analysis in OpenSceneGraph-2.8.0 I discovered the following lines of code in View.cpp:
osg::DisplaySettings* ds = osg::DisplaySettings::instance();
if (ds->getStereo())
{
switch(ds->getStereoMode())
{
case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;
case(osg::DisplaySettings::VERTICAL_INTERLACE):
case(osg::DisplaySettings::CHECKERBOARD):
case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;
default: break;
}
}
It seems that the stereo context in FlightGear does not get initialized properly in WindowBuilder::makeDefaultTraits(bool stencil). Thus these lines have to be added to WindowBuilder.cxx. For convenience here is the patch against FlightGear-2.0.0: [download#43]
Perhaps some nice FlightGear developer can include this into upstream code. You have to use a professional graphics board that supports quad buffered stereo, like a NVIDIA Quadro FX or a Ati FireGL and proper display hardware, like shutter glasses, a HMD or a stereoscopic projection system, to benefit from it.
Problems remaining
When using the quad buffered stereo mode in flightgear there occur some graphics errors. These are not very annoying, but they are there. Some cockpit controls and other scene details contain yellow lines, like a wireframe, which are not there when starting FlightGear in “normal” display mode. I suspect this to be another bug in FlightGear, which has still to be located. See the screenshots below for details. The problematic parts of the scenes are marked red. Especially the night pictures show the problem. This problem does not only exist in quad buffered stereo mode, but also in other stereo modes like HORIZONTAL_SPLIT.
The Gentoo way
For gentoo users here is my overlay including the modified ebuild: [download#44] Download the modified overlay (including the patches) and extract it in /usr/local/portage. Be sure to include the following line in your /etc/make.conf:
PORTDIR_OVERLAY=”/usr/local/portage”
Then emerge flightgear and enjoy it in three dimensions.
Have fun
Jürgen