Added to Viewer::realize() automatic setup using Keystone when available and enabled, and when no other window setup has been selected.

This commit is contained in:
Robert Osfield 2013-05-13 09:18:37 +00:00
parent 9402efe38e
commit 4e34cadee2
4 changed files with 25 additions and 8 deletions

View File

@ -100,7 +100,7 @@ int main( int argc, char **argv )
if (ds->getStereo()) if (ds->getStereo())
{ {
viewer.setUpViewForStereo(ds); viewer.setUpViewForStereo();
} }
else else
{ {

View File

@ -263,7 +263,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
osg::Camera* assignRenderToTextureCamera(osg::GraphicsContext* gc, int width, int height, osg::Texture* texture); osg::Camera* assignRenderToTextureCamera(osg::GraphicsContext* gc, int width, int height, osg::Texture* texture);
osg::Camera* assignKeystoneDistortionCamera(osg::DisplaySettings* ds, osg::GraphicsContext* gc, int x, int y, int width, int height, GLenum buffer, osg::Texture* texture, Keystone* keystone); osg::Camera* assignKeystoneDistortionCamera(osg::DisplaySettings* ds, osg::GraphicsContext* gc, int x, int y, int width, int height, GLenum buffer, osg::Texture* texture, Keystone* keystone);
osg::Camera* assignStereoCamera(osg::DisplaySettings* ds, osg::GraphicsContext* gc, int x, int y, int width, int height, GLenum buffer, double eyeScale); osg::Camera* assignStereoCamera(osg::DisplaySettings* ds, osg::GraphicsContext* gc, int x, int y, int width, int height, GLenum buffer, double eyeScale);
void setUpViewForStereo(osg::DisplaySettings* ds); void setUpViewForStereo();
void setUpViewForKeystone(Keystone* keystone); void setUpViewForKeystone(Keystone* keystone);
struct StereoSlaveCallback : public osg::View::Slave::UpdateSlaveCallback struct StereoSlaveCallback : public osg::View::Slave::UpdateSlaveCallback

View File

@ -2490,8 +2490,9 @@ static const GLubyte patternCheckerboard[] = {
0xAA, 0xAA, 0xAA, 0xAA}; 0xAA, 0xAA, 0xAA, 0xAA};
void View::setUpViewForStereo(osg::DisplaySettings* ds) void View::setUpViewForStereo()
{ {
osg::DisplaySettings* ds = _displaySettings.valid() ? _displaySettings.get() : osg::DisplaySettings::instance().get();
if (!ds->getStereo()) return; if (!ds->getStereo()) return;
ds->setUseSceneViewForStereoHint(false); ds->setUseSceneViewForStereoHint(false);

View File

@ -464,6 +464,21 @@ void Viewer::realize()
if (screenNum>=0) setUpViewInWindow(x, y, width, height, screenNum); if (screenNum>=0) setUpViewInWindow(x, y, width, height, screenNum);
else setUpViewInWindow(x,y,width,height); else setUpViewInWindow(x,y,width,height);
} }
else
{
osg::DisplaySettings* ds = _displaySettings.valid() ? _displaySettings.get() : osg::DisplaySettings::instance().get();
if (ds->getKeystoneHint() && !ds->getKeystoneFileNames().empty()) osgViewer::Keystone::loadKeystoneFiles(ds);
bool useKeystones = ds->getKeystoneHint() && !ds->getKeystones().empty();
if (ds->getStereo() && (!ds->getUseSceneViewForStereoHint() || useKeystones))
{
setUpViewForStereo();
}
else if (useKeystones)
{
osgViewer::Keystone* keystone = dynamic_cast<osgViewer::Keystone*>(ds->getKeystones().front().get());
setUpViewForKeystone(keystone);
}
else if (screenNum>=0) else if (screenNum>=0)
{ {
setUpViewOnSingleScreen(screenNum); setUpViewOnSingleScreen(screenNum);
@ -473,6 +488,7 @@ void Viewer::realize()
setUpViewAcrossAllScreens(); setUpViewAcrossAllScreens();
} }
} }
}
getContexts(contexts); getContexts(contexts);
} }