From 36b5e5901950c95230dfd6c6e44559ca5238906c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 27 Nov 2009 15:32:43 +0000 Subject: [PATCH] From Paul Martz, "This change address the following issue: an app opens a Viewer on a multidisplay system, configured to setUpViewAcrossAllDisplays, with a non-default clear mask. In this case, OSG failed to propagate the clear mask to the slave Cameras, resulting in the clear mask being ignored. To fix this issue, this revision adds a new CullSettings::VariablesMask bit, CLEAR_MASK, to explicitly control inheritance of the clear mask. This bit is set by default, which means that the clear mask now inherits by default, whereas previously it did not." --- include/osg/Camera | 2 +- include/osg/CullSettings | 37 +++++++++++++++++++------------------ src/osg/Camera.cpp | 3 +++ src/osgUtil/CullVisitor.cpp | 8 ++++++++ 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/include/osg/Camera b/include/osg/Camera index b1d5b538f..5c733e2b8 100644 --- a/include/osg/Camera +++ b/include/osg/Camera @@ -84,7 +84,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings /** Set the clear mask used in glClear(..). * Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */ - inline void setClearMask(GLbitfield mask) { _clearMask = mask; } + inline void setClearMask(GLbitfield mask) { _clearMask = mask; applyMaskAction(CLEAR_MASK); } /** Get the clear mask.*/ inline GLbitfield getClearMask() const { return _clearMask; } diff --git a/include/osg/CullSettings b/include/osg/CullSettings index 617f7251a..b0da3ad57 100644 --- a/include/osg/CullSettings +++ b/include/osg/CullSettings @@ -58,24 +58,25 @@ class OSG_EXPORT CullSettings enum VariablesMask { - COMPUTE_NEAR_FAR_MODE = 0x00000001, - CULLING_MODE = 0x00000002, - LOD_SCALE = 0x00000004, - SMALL_FEATURE_CULLING_PIXEL_SIZE = 0x00000008, - CLAMP_PROJECTION_MATRIX_CALLBACK = 0x00000010, - NEAR_FAR_RATIO = 0x00000020, - IMPOSTOR_ACTIVE = 0x00000040, - DEPTH_SORT_IMPOSTOR_SPRITES = 0x00000080, - IMPOSTOR_PIXEL_ERROR_THRESHOLD = 0x00000100, - NUM_FRAMES_TO_KEEP_IMPOSTORS_SPRITES = 0x00000200, - CULL_MASK = 0x00000400, - CULL_MASK_LEFT = 0x00000800, - CULL_MASK_RIGHT = 0x00001000, - CLEAR_COLOR = 0x00002000, - LIGHTING_MODE = 0x00004000, - LIGHT = 0x00008000, - DRAW_BUFFER = 0x00010000, - READ_BUFFER = 0x00020000, + COMPUTE_NEAR_FAR_MODE = (0x1 << 0), + CULLING_MODE = (0x1 << 1), + LOD_SCALE = (0x1 << 2), + SMALL_FEATURE_CULLING_PIXEL_SIZE = (0x1 << 3), + CLAMP_PROJECTION_MATRIX_CALLBACK = (0x1 << 4), + NEAR_FAR_RATIO = (0x1 << 5), + IMPOSTOR_ACTIVE = (0x1 << 6), + DEPTH_SORT_IMPOSTOR_SPRITES = (0x1 << 7), + IMPOSTOR_PIXEL_ERROR_THRESHOLD = (0x1 << 8), + NUM_FRAMES_TO_KEEP_IMPOSTORS_SPRITES = (0x1 << 9), + CULL_MASK = (0x1 << 10), + CULL_MASK_LEFT = (0x1 << 11), + CULL_MASK_RIGHT = (0x1 << 12), + CLEAR_COLOR = (0x1 << 13), + CLEAR_MASK = (0x1 << 14), + LIGHTING_MODE = (0x1 << 15), + LIGHT = (0x1 << 16), + DRAW_BUFFER = (0x1 << 17), + READ_BUFFER = (0x1 << 18), NO_VARIABLES = 0x00000000, ALL_VARIABLES = 0xFFFFFFFF diff --git a/src/osg/Camera.cpp b/src/osg/Camera.cpp index 487fb1256..94c74d0a2 100644 --- a/src/osg/Camera.cpp +++ b/src/osg/Camera.cpp @@ -397,6 +397,9 @@ void Camera::inheritCullSettings(const CullSettings& settings, unsigned int inhe if (inheritanceMask & CLEAR_COLOR) _clearColor = camera->_clearColor; + if (inheritanceMask & CLEAR_MASK) + _clearMask = camera->_clearMask; + if (inheritanceMask & DRAW_BUFFER) _drawBuffer = camera->_drawBuffer; diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 5d5c891c4..2b5870c5e 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -1304,6 +1304,14 @@ void CullVisitor::apply(osg::Camera& camera) { rtts->setClearColor(camera.getClearColor()); } + if (camera.getInheritanceMask() & CLEAR_MASK) + { + rtts->setClearMask(previous_stage->getClearMask()); + } + else + { + rtts->setClearMask(camera.getClearMask()); + } // set the color mask.