From b93581e687c6076d03b3e1ccdacb1463f3e66ac5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 8 Apr 2009 14:08:16 +0000 Subject: [PATCH] From Cory Riddell, fix for aspect ratio --- examples/osgviewerMFC/MFC_OSG.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/osgviewerMFC/MFC_OSG.cpp b/examples/osgviewerMFC/MFC_OSG.cpp index 01d5c73b0..aef0f8ac1 100644 --- a/examples/osgviewerMFC/MFC_OSG.cpp +++ b/examples/osgviewerMFC/MFC_OSG.cpp @@ -116,6 +116,12 @@ void cOSG::InitCameraConfig(void) // Realize the Viewer mViewer->realize(); + + // Correct aspect ratio + double fovy,aspectRatio,z1,z2; + mViewer->getCamera()->getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2); + aspectRatio=double(traits->width)/double(traits->height); + mViewer->getCamera()->setProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2); } void cOSG::PreFrameUpdate()