Added use of SingleWindow for when only one screen is used
This commit is contained in:
@@ -452,7 +452,7 @@ void View::apply(ViewConfig* config)
|
||||
{
|
||||
if (config)
|
||||
{
|
||||
OSG_NOTICE<<"Applying osgViewer::ViewConfig : "<<config->className()<<std::endl;
|
||||
OSG_INFO<<"Applying osgViewer::ViewConfig : "<<config->className()<<std::endl;
|
||||
config->configure(*this);
|
||||
}
|
||||
_lastAppliedViewConfig = config;
|
||||
@@ -1413,9 +1413,9 @@ void View::assignStereoOrKeystoneToCamera(osg::Camera* camera, osg::DisplaySetti
|
||||
|
||||
// set up view's main camera
|
||||
{
|
||||
double height = osg::DisplaySettings::instance()->getScreenHeight();
|
||||
double width = osg::DisplaySettings::instance()->getScreenWidth();
|
||||
double distance = osg::DisplaySettings::instance()->getScreenDistance();
|
||||
double height = ds->getScreenHeight();
|
||||
double width = ds->getScreenWidth();
|
||||
double distance = ds->getScreenDistance();
|
||||
double vfov = osg::RadiansToDegrees(atan2(height/2.0f,distance)*2.0);
|
||||
|
||||
camera->setProjectionMatrixAsPerspective( vfov, width/height, 1.0f,10000.0f);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <osgViewer/config/AcrossAllScreens>
|
||||
#include <osgViewer/config/SingleScreen>
|
||||
#include <osgViewer/Renderer>
|
||||
#include <osgViewer/View>
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
@@ -43,52 +44,8 @@ void AcrossAllScreens::configure(osgViewer::View& view) const
|
||||
unsigned int numScreens = wsi->getNumScreens(si);
|
||||
if (numScreens==1)
|
||||
{
|
||||
if (si.screenNum<0) si.screenNum = 0;
|
||||
|
||||
unsigned int width, height;
|
||||
wsi->getScreenResolution(si, width, height);
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds);
|
||||
traits->hostName = si.hostName;
|
||||
traits->displayNum = si.displayNum;
|
||||
traits->screenNum = si.screenNum;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
view.getCamera()->setGraphicsContext(gc.get());
|
||||
|
||||
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
|
||||
if (gw)
|
||||
{
|
||||
OSG_INFO<<" GraphicsWindow has been created successfully."<<std::endl;
|
||||
gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height );
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<" GraphicsWindow has not been created successfully."<<std::endl;
|
||||
}
|
||||
|
||||
double newAspectRatio = double(traits->width) / double(traits->height);
|
||||
double aspectRatioChange = newAspectRatio / aspectRatio;
|
||||
if (aspectRatioChange != 1.0)
|
||||
{
|
||||
view.getCamera()->getProjectionMatrix() *= osg::Matrix::scale(1.0/aspectRatioChange,1.0,1.0);
|
||||
}
|
||||
|
||||
view.getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
|
||||
|
||||
GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
|
||||
|
||||
view.getCamera()->setDrawBuffer(buffer);
|
||||
view.getCamera()->setReadBuffer(buffer);
|
||||
|
||||
osg::ref_ptr<SingleScreen> ss = new SingleScreen(0);
|
||||
ss->configure(view);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -82,6 +82,7 @@ void SingleWindow::configure(osgViewer::View& view) const
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<" GraphicsWindow has not been created successfully."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
double fovy, aspectRatio, zNear, zFar;
|
||||
@@ -101,8 +102,6 @@ void SingleWindow::configure(osgViewer::View& view) const
|
||||
view.getCamera()->setDrawBuffer(buffer);
|
||||
view.getCamera()->setReadBuffer(buffer);
|
||||
|
||||
OSG_NOTICE<<"Here"<<std::endl;
|
||||
|
||||
if (ds->getKeystoneHint())
|
||||
{
|
||||
if (ds->getKeystoneHint() && !ds->getKeystoneFileNames().empty())
|
||||
|
||||
Reference in New Issue
Block a user