Introduced osg::Camera::resize(..) method and associated enum thus:

enum ResizeMask
        {
            RESIZE_VIEWPORT=1,
            RESIZE_ATTACHMENTS=2,
            RESIZE_PROJECTIONMATRIX=4,
            RESIZE_DEFAULT=RESIZE_VIEWPORT|RESIZE_ATTACHMENTS
        };

        /** Resize, to the specified width and height, the viewport, attachments and projection matrix according to the resizeMask provided.
          * Note, the adjustment of the projection matrix is done if the RESIZE_PROJECTIONMATRIX mask to set and according to the rules specified in the ProjectionResizePolicy. */
        void resize(int width, int height, int resizeMask=RESIZE_DEFAULT);



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14811 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2015-03-31 16:23:43 +00:00
parent 99f7bfab3b
commit a7ba138dc7
3 changed files with 56 additions and 12 deletions

View File

@@ -481,6 +481,47 @@ void Camera::resizeAttachments(int width, int height)
}
}
void Camera::resize(int width, int height, int resizeMask)
{
if (getViewport())
{
double previousWidth = getViewport()->width();
double previousHeight = getViewport()->height();
double newWidth = width;
double newHeight = height;
if ((previousWidth!=newWidth) || (previousHeight!=newHeight))
{
if ((resizeMask&RESIZE_PROJECTIONMATRIX)!=0 && (getProjectionResizePolicy()!=FIXED))
{
double widthChangeRatio = newWidth / previousWidth;
double heigtChangeRatio = newHeight / previousHeight;
double aspectRatioChange = widthChangeRatio / heigtChangeRatio;
if (aspectRatioChange!=1.0)
{
switch(getProjectionResizePolicy())
{
case(HORIZONTAL): getProjectionMatrix() *= osg::Matrix::scale(1.0/aspectRatioChange,1.0,1.0); break;
case(VERTICAL): getProjectionMatrix() *= osg::Matrix::scale(1.0, aspectRatioChange,1.0); break;
case(FIXED): break;
}
}
}
if ((resizeMask&RESIZE_VIEWPORT)!=0)
{
setViewport(0,0,width, height);
}
}
}
if ((resizeMask&RESIZE_ATTACHMENTS)!=0)
{
resizeAttachments(width, height);
}
}
void Camera::createCameraThread()
{
if (!_cameraThread)