Added setting of the Camera's projection matrix to fit the windowing aspect ratio.

This commit is contained in:
Robert Osfield 2007-06-23 11:21:54 +00:00
parent 4a315e47fe
commit 581b1c322e
4 changed files with 5 additions and 1 deletions

View File

@ -658,7 +658,7 @@ int main(int argc, char **argv)
// construct the viewer.
osgViewer::Viewer viewer;
osgViewer::Viewer viewer(arguments);
// if user request help write it out to cout.
unsigned int testCase = 0;

View File

@ -102,6 +102,7 @@ class ViewerFLTK : public osgViewer::Viewer, public AdapterWidget
AdapterWidget(x,y,w,h,label)
{
getCamera()->setViewport(new osg::Viewport(0,0,w,h));
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(w)/static_cast<double>(h), 1.0f, 10000.0f);
getCamera()->setGraphicsContext(getGraphicsWindow());
setThreadingModel(osgViewer::Viewer::SingleThreaded);
}

View File

@ -147,6 +147,8 @@ class ViewerQT : public osgViewer::Viewer, public AdapterWidget
{
getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
getCamera()->setGraphicsContext(getGraphicsWindow());
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);
setThreadingModel(osgViewer::Viewer::SingleThreaded);
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));

View File

@ -825,6 +825,7 @@ GraphicsWindowEmbedded* Viewer::setUpViewerAsEmbeddedInWindow(int x, int y, int
setThreadingModel(SingleThreaded);
osgViewer::GraphicsWindowEmbedded* gw = new osgViewer::GraphicsWindowEmbedded(x,y,width,height);
getCamera()->setViewport(new osg::Viewport(0,0,width,height));
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width)/static_cast<double>(height), 1.0f, 10000.0f);
getCamera()->setGraphicsContext(gw);
return gw;
}