Commit 237eb386 authored by cornimueller's avatar cornimueller
Browse files

[ADD] GL views are adjusted on window resizes, so the aspect ratio is correct

parent eba0f635
......@@ -54,9 +54,11 @@ WGEViewer::WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, i
m_View = osg::ref_ptr<osgViewer::Viewer>( new osgViewer::Viewer() );
m_View->getCamera()->setGraphicsContext( m_GraphicsContext );
// m_View->getCamera()->setProjectionMatrixAsPerspective( 30.0f, 1.333, 1.0, 1000.0 );
m_View->getCamera()->setProjectionMatrixAsOrtho( -120, 120, -120, 120, -1000, +1000 );
m_View->getCamera()->setViewport( new osg::Viewport( 0, 0, 10, 10 ) );
// m_View->getCamera()->setProjectionMatrixAsPerspective(
// 30.0, static_cast< double >( width ) / static_cast< double >( height ), 1.0, 1000.0 );
m_View->getCamera()->setProjectionMatrixAsOrtho( -120.0 * width / height, 120.0 * width / height, -120.0, 120.0, -1000.0, +1000.0 );
m_View->getCamera()->setViewport( 0, 0, width, height );
m_View->getCamera()->setProjectionResizePolicy( osg::Camera::HORIZONTAL );
// add the stats handler
m_View->addEventHandler( new osgViewer::StatsHandler );
......@@ -128,9 +130,7 @@ void WGEViewer::resize( int width, int height )
WGEGraphicsWindow::resize( width, height );
// also update the camera
// m_View->getCamera()->setProjectionMatrixAsPerspective( 30.0f, 1.333, 1.0, 1000.0 );
m_View->getCamera()->setProjectionMatrixAsOrtho( -120, 120, -120, 120, -1000, +1000 );
m_View->getCamera()->setViewport( new osg::Viewport( 0, 0, width, height ) );
m_View->getCamera()->setViewport( 0, 0, width, height );
}
void WGEViewer::close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment