Added range checking to osg::Camera::adjustAspectRatio to catch invalid values being

passed to Camera.  Invalid values were occuring when iconising the Windows GLUT
based OSG demos.
This commit is contained in:
Robert Osfield
2001-12-18 11:28:44 +00:00
parent 13641f1d6c
commit a3fe8ebb18

View File

@@ -218,6 +218,12 @@ void Camera::setNearFar(const double zNear, const double zFar)
* Typicall used after resizeing a window.*/
void Camera::adjustAspectRatio(const double newAspectRatio, const AdjustAspectRatioMode aa)
{
if (newAspectRatio<0.01f || newAspectRatio>100.0f)
{
notify(NOTICE)<<"Warning: aspect ratio out of range (0.01..100) in Camera::adjustAspectRatio("<<newAspectRatio<<","<<aa<<")"<<std::endl;
return;
}
double previousAspectRatio = (_right-_left)/(_top-_bottom);
double deltaRatio = newAspectRatio/previousAspectRatio;
if (aa == ADJUST_HORIZONTAL)