From cce656a19b1d3522c9098ee92ec47f7446717aec Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 4 Jan 2007 16:48:23 +0000 Subject: [PATCH] Fixed warnings --- src/osgUtil/RenderStage.cpp | 84 ++++++++++++++++++++----------------- src/osgUtil/SceneView.cpp | 50 ++++++++++++++-------- 2 files changed, 78 insertions(+), 56 deletions(-) diff --git a/src/osgUtil/RenderStage.cpp b/src/osgUtil/RenderStage.cpp index 7acaa1317..84c3e37e6 100644 --- a/src/osgUtil/RenderStage.cpp +++ b/src/osgUtil/RenderStage.cpp @@ -224,8 +224,8 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo) osg::Camera::BufferAttachmentMap& bufferAttachements = _camera->getBufferAttachmentMap(); // compute the required dimensions - int width = _viewport->x() + _viewport->width(); - int height = _viewport->y() + _viewport->height(); + int width = static_cast(_viewport->x() + _viewport->width()); + int height = static_cast(_viewport->y() + _viewport->height()); int depth = 1; osg::Camera::BufferAttachmentMap::iterator itr; for(itr = bufferAttachements.begin(); @@ -635,60 +635,61 @@ void RenderStage::copyTexture(osg::RenderInfo& renderInfo) osg::TextureRectangle* textureRec = 0; osg::TextureCubeMap* textureCubeMap = 0; -#if 1 // use TexCopySubImage with the offset of the viewport into the texture // note, this path mirrors the pbuffer and fbo means for updating the texture. // Robert Osfield, 3rd August 2006. if ((texture2D = dynamic_cast(_texture.get())) != 0) { - texture2D->copyTexSubImage2D(state,_viewport->x(),_viewport->y(), _viewport->x(),_viewport->y(),_viewport->width(),_viewport->height()); + texture2D->copyTexSubImage2D(state, + static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->width()), + static_cast(_viewport->height())); } else if ((textureRec = dynamic_cast(_texture.get())) != 0) { - textureRec->copyTexSubImage2D(state,_viewport->x(),_viewport->y(), _viewport->x(),_viewport->y(),_viewport->width(),_viewport->height()); + textureRec->copyTexSubImage2D(state, + static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->width()), + static_cast(_viewport->height())); } else if ((texture1D = dynamic_cast(_texture.get())) != 0) { // need to implement - texture1D->copyTexSubImage1D(state,_viewport->x(), _viewport->x(),_viewport->y(),_viewport->width()); + texture1D->copyTexSubImage1D(state, + static_cast(_viewport->x()), + static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->width())); } else if ((texture3D = dynamic_cast(_texture.get())) != 0) { // need to implement - texture3D->copyTexSubImage3D(state, _viewport->x(), _viewport->y(), _face, _viewport->x(), _viewport->y(), _viewport->width(), _viewport->height()); + texture3D->copyTexSubImage3D(state, + static_cast(_viewport->x()), + static_cast(_viewport->y()), + _face, + static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->width()), + static_cast(_viewport->height())); } else if ((textureCubeMap = dynamic_cast(_texture.get())) != 0) { // need to implement - textureCubeMap->copyTexSubImageCubeMap(state, _face, _viewport->x(), _viewport->y(), _viewport->x(),_viewport->y(),_viewport->width(),_viewport->height()); + textureCubeMap->copyTexSubImageCubeMap(state, _face, + static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->width()), + static_cast(_viewport->height())); } -#else - // use CopySubImage with the offset set to 0,0 - // original code path. - if ((texture2D = dynamic_cast(_texture.get())) != 0) - { - texture2D->copyTexImage2D(state,_viewport->x(),_viewport->y(),_viewport->width(),_viewport->height()); - } - else if ((textureRec = dynamic_cast(_texture.get())) != 0) - { - textureRec->copyTexImage2D(state,_viewport->x(),_viewport->y(),_viewport->width(),_viewport->height()); - } - else if ((texture1D = dynamic_cast(_texture.get())) != 0) - { - // need to implement - texture1D->copyTexImage1D(state,_viewport->x(),_viewport->y(),_viewport->width()); - } - else if ((texture3D = dynamic_cast(_texture.get())) != 0) - { - // need to implement - texture3D->copyTexSubImage3D(state, 0, 0, _face, _viewport->x(), _viewport->y(), _viewport->width(), _viewport->height()); - } - else if ((textureCubeMap = dynamic_cast(_texture.get())) != 0) - { - // need to implement - textureCubeMap->copyTexSubImageCubeMap(state, _face, 0, 0, _viewport->x(),_viewport->y(),_viewport->width(),_viewport->height()); - } -#endif } void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, bool& doCopyTexture) @@ -753,9 +754,11 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b if (dataType==0) dataType = _imageReadPixelDataType; if (dataType==0) dataType = GL_UNSIGNED_BYTE; - itr->second._image->readPixels(_viewport->x(), _viewport->y(), - _viewport->width(), _viewport->height(), - pixelFormat, dataType); + itr->second._image->readPixels(static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->width()), + static_cast(_viewport->height()), + pixelFormat, dataType); } } @@ -922,7 +925,10 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr #define USE_SISSOR_TEST #ifdef USE_SISSOR_TEST - glScissor( _viewport->x(), _viewport->y(), _viewport->width(), _viewport->height() ); + glScissor( static_cast(_viewport->x()), + static_cast(_viewport->y()), + static_cast(_viewport->width()), + static_cast(_viewport->height()) ); //cout << " clearing "<x()<<","<< _viewport->y()<<","<< _viewport->width()<<","<< _viewport->height()<drawPreRenderStages(_renderInfo,previous); _renderStageRight->drawPreRenderStages(_renderInfo,previous); - int separation = _displaySettings->getSplitStereoHorizontalSeparation(); + double separation = _displaySettings->getSplitStereoHorizontalSeparation(); - int left_half_width = (getViewport()->width()-separation)/2; - int right_half_begin = (getViewport()->width()+separation)/2; - int right_half_width = getViewport()->width()-right_half_begin; + double left_half_width = (getViewport()->width()-separation)/2.0; + double right_half_begin = (getViewport()->width()+separation)/2.0; + double right_half_width = getViewport()->width()-right_half_begin; osg::ref_ptr viewportLeft = new osg::Viewport; viewportLeft->setViewport(getViewport()->x(),getViewport()->y(),left_half_width,getViewport()->height()); @@ -981,8 +981,10 @@ void SceneView::draw() osg::ref_ptr viewportRight = new osg::Viewport; viewportRight->setViewport(getViewport()->x()+right_half_begin,getViewport()->y(),right_half_width,getViewport()->height()); - - clearArea(getViewport()->x()+left_half_width,getViewport()->y(),separation,getViewport()->height(),_renderStageLeft->getClearColor()); + clearArea(static_cast(getViewport()->x()+left_half_width), + static_cast(getViewport()->y()), + static_cast(separation), + static_cast(getViewport()->height()),_renderStageLeft->getClearColor()); if (_displaySettings->getSplitStereoHorizontalEyeMapping()==osg::DisplaySettings::LEFT_EYE_LEFT_VIEWPORT) { @@ -1035,11 +1037,11 @@ void SceneView::draw() _renderStageLeft->drawPreRenderStages(_renderInfo,previous); _renderStageRight->drawPreRenderStages(_renderInfo,previous); - int separation = _displaySettings->getSplitStereoVerticalSeparation(); + double separation = _displaySettings->getSplitStereoVerticalSeparation(); - int bottom_half_height = (getViewport()->height()-separation)/2; - int top_half_begin = (getViewport()->height()+separation)/2; - int top_half_height = getViewport()->height()-top_half_begin; + double bottom_half_height = (getViewport()->height()-separation)/2.0; + double top_half_begin = (getViewport()->height()+separation)/2.0; + double top_half_height = getViewport()->height()-top_half_begin; osg::ref_ptr viewportTop = new osg::Viewport; viewportTop->setViewport(getViewport()->x(),getViewport()->y()+top_half_begin,getViewport()->width(),top_half_height); @@ -1047,7 +1049,11 @@ void SceneView::draw() osg::ref_ptr viewportBottom = new osg::Viewport; viewportBottom->setViewport(getViewport()->x(),getViewport()->y(),getViewport()->width(),bottom_half_height); - clearArea(getViewport()->x(),getViewport()->y()+bottom_half_height,getViewport()->width(),separation,_renderStageLeft->getClearColor()); + clearArea(static_cast(getViewport()->x()), + static_cast(getViewport()->y()+bottom_half_height), + static_cast(getViewport()->width()), + static_cast(separation), + _renderStageLeft->getClearColor()); if (_displaySettings->getSplitStereoVerticalEyeMapping()==osg::DisplaySettings::LEFT_EYE_TOP_VIEWPORT) { @@ -1141,15 +1147,20 @@ void SceneView::draw() glPolygonStipple(patternVertEven); glEnable(GL_POLYGON_STIPPLE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - glRecti(getViewport()->x(), getViewport()->y(), getViewport()->width(), getViewport()->height()); + + glRecti(static_cast(getViewport()->x()), + static_cast(getViewport()->y()), + static_cast(getViewport()->width()), + static_cast(getViewport()->height()) ); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDisable(GL_POLYGON_STIPPLE); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); _redrawInterlacedStereoStencilMask = false; - _interlacedStereoStencilWidth = getViewport()->width(); - _interlacedStereoStencilHeight = getViewport()->height(); + _interlacedStereoStencilWidth = static_cast(getViewport()->width()); + _interlacedStereoStencilHeight = static_cast(getViewport()->height()); } _renderStageLeft->setClearMask(_renderStageLeft->getClearMask() & ~(GL_STENCIL_BUFFER_BIT)); @@ -1206,15 +1217,20 @@ void SceneView::draw() glPolygonStipple(patternHorzEven); glEnable(GL_POLYGON_STIPPLE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - glRecti(getViewport()->x(), getViewport()->y(), getViewport()->width(), getViewport()->height()); + + glRecti(static_cast(getViewport()->x()), + static_cast(getViewport()->y()), + static_cast(getViewport()->width()), + static_cast(getViewport()->height()) ); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDisable(GL_POLYGON_STIPPLE); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); _redrawInterlacedStereoStencilMask = false; - _interlacedStereoStencilWidth = getViewport()->width(); - _interlacedStereoStencilHeight = getViewport()->height(); + _interlacedStereoStencilWidth = static_cast(getViewport()->width()); + _interlacedStereoStencilHeight = static_cast(getViewport()->height()); } _renderStageLeft->setClearMask(_renderStageLeft->getClearMask() & ~(GL_STENCIL_BUFFER_BIT));