From 64f8631d9d5195094ffd7f0c55eb82d44f6a9595 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 31 Mar 2008 11:44:31 +0000 Subject: [PATCH] Added Camera::s/getClearAccum, s/getClearStencil and s/getClearDepth. --- include/osg/Camera | 41 ++++++++++++++++++---- include/osgUtil/RenderStage | 5 +-- include/osgUtil/SceneView | 1 + src/osg/Camera.cpp | 10 ++++-- src/osgUtil/SceneView.cpp | 5 ++- src/osgWrappers/osg/Camera.cpp | 63 +++++++++++++++++++++++++++------- 6 files changed, 99 insertions(+), 26 deletions(-) diff --git a/include/osg/Camera b/include/osg/Camera index 1f38bbed3..e7cce333b 100644 --- a/include/osg/Camera +++ b/include/osg/Camera @@ -82,12 +82,6 @@ class OSG_EXPORT Camera : public Transform, public CullSettings const osg::DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); } - /** Sets the clear color. */ - inline void setClearColor(const Vec4& color) { _clearColor = color; } - - /** Returns the clear color. */ - inline const Vec4& getClearColor() const { return _clearColor; } - /** Set the clear mask used in glClear(..). * Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */ inline void setClearMask(GLbitfield mask) { _clearMask = mask; } @@ -95,10 +89,39 @@ class OSG_EXPORT Camera : public Transform, public CullSettings /** Get the clear mask.*/ inline GLbitfield getClearMask() const { return _clearMask; } + /** Set the clear color used in glClearColor(..). + * glClearColor is only called if mask & GL_COLOR_BUFFER_BIT is true*/ + void setClearColor(const osg::Vec4& color) { _clearColor=color; } + + /** Get the clear color.*/ + const osg::Vec4& getClearColor() const { return _clearColor; } + + /** Set the clear accum used in glClearAccum(..). + * glClearAcumm is only called if mask & GL_ACCUM_BUFFER_BIT is true. */ + void setClearAccum(const osg::Vec4& color) { _clearAccum=color; } + + /** Get the clear accum value.*/ + const osg::Vec4& getClearAccum() const { return _clearAccum; } + + /** Set the clear depth used in glClearDepth(..). Defaults to 1.0 + * glClearDepth is only called if mask & GL_DEPTH_BUFFER_BIT is true. */ + void setClearDepth(double depth) { _clearDepth=depth; } + + /** Get the clear depth value.*/ + double getClearDepth() const { return _clearDepth; } + /** Set the clear stencil value used in glClearStencil(). Defaults to 0; + * glClearStencil is only called if mask & GL_STENCIL_BUFFER_BIT is true*/ + void setClearStencil(int stencil) { _clearStencil=stencil; } + + /** Get the clear stencil value.*/ + int getClearStencil() const { return _clearStencil; } + + /** Set the color mask of the camera to use specified osg::ColorMask. */ void setColorMask(osg::ColorMask* colorMask); + /** Set the color mask of the camera to specified values. */ void setColorMask(bool red, bool green, bool blue, bool alpha); @@ -483,8 +506,12 @@ class OSG_EXPORT Camera : public Transform, public CullSettings osg::ref_ptr _displaySettings; - Vec4 _clearColor; GLbitfield _clearMask; + osg::Vec4 _clearColor; + osg::Vec4 _clearAccum; + double _clearDepth; + int _clearStencil; + ref_ptr _colorMask; ref_ptr _viewport; diff --git a/include/osgUtil/RenderStage b/include/osgUtil/RenderStage index a0c772f5e..15c0d2fad 100644 --- a/include/osgUtil/RenderStage +++ b/include/osgUtil/RenderStage @@ -94,7 +94,6 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin /** Get the clear color.*/ const osg::Vec4& getClearColor() const { return _clearColor; } - /** Set the clear accum used in glClearAccum(..). * glClearAcumm is only called if mask & GL_ACCUM_BUFFER_BIT is true. */ void setClearAccum(const osg::Vec4& color) { _clearAccum=color; } @@ -102,8 +101,6 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin /** Get the clear accum.*/ const osg::Vec4& getClearAccum() const { return _clearAccum; } - - /** Set the clear depth used in glClearDepth(..). Defaults to 1.0 * glClearDepth is only called if mask & GL_DEPTH_BUFFER_BIT is true. */ void setClearDepth(double depth) { _clearDepth=depth; } @@ -111,13 +108,13 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin /** Get the clear depth.*/ double getClearDepth() const { return _clearDepth; } - /** Set the clear stencil value used in glClearStencil(). Defaults to 0; * glClearStencil is only called if mask & GL_STENCIL_BUFFER_BIT is true*/ void setClearStencil(int stencil) { _clearStencil=stencil; } /** Get the clear color.*/ int getClearStencil() const { return _clearStencil; } + void setCamera(osg::Camera* camera) { if (_camera!=camera) { _camera = camera; _cameraRequiresSetUp = true; } } osg::Camera* getCamera() { return _camera; } diff --git a/include/osgUtil/SceneView b/include/osgUtil/SceneView index 1a0c50e57..01247dff2 100644 --- a/include/osgUtil/SceneView +++ b/include/osgUtil/SceneView @@ -113,6 +113,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings /** Set the color used in glClearColor(). Defaults to an off blue color.*/ void setClearColor(const osg::Vec4& color) { _camera->setClearColor(color); } + /** Get the color used in glClearColor.*/ const osg::Vec4& getClearColor() const { return _camera->getClearColor(); } diff --git a/src/osg/Camera.cpp b/src/osg/Camera.cpp index 2e012d297..41834b5c1 100644 --- a/src/osg/Camera.cpp +++ b/src/osg/Camera.cpp @@ -19,8 +19,11 @@ using namespace osg; Camera::Camera(): _view(0), _allowEventFocus(true), - _clearColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)), _clearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT), + _clearColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)), + _clearAccum(osg::Vec4(0.0f,0.0f,0.0f,1.0f)), + _clearDepth(1.0), + _clearStencil(0), _transformOrder(PRE_MULTIPLY), _projectionResizePolicy(HORIZONTAL), _renderOrder(POST_RENDER), @@ -39,8 +42,11 @@ Camera::Camera(const Camera& camera,const CopyOp& copyop): _view(camera._view), _allowEventFocus(camera._allowEventFocus), _displaySettings(camera._displaySettings), - _clearColor(camera._clearColor), _clearMask(camera._clearMask), + _clearColor(camera._clearColor), + _clearAccum(camera._clearAccum), + _clearDepth(camera._clearDepth), + _clearStencil(camera._clearStencil), _colorMask(camera._colorMask), _viewport(camera._viewport), _transformOrder(camera._transformOrder), diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 1aedf8916..a749cff28 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -780,7 +780,10 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod rendergraph->clean(); renderStage->setViewport(getViewport()); - renderStage->setClearColor(getClearColor()); + renderStage->setClearColor(_camera->getClearColor()); + renderStage->setClearDepth(_camera->getClearDepth()); + renderStage->setClearAccum(_camera->getClearAccum()); + renderStage->setClearStencil(_camera->getClearStencil()); renderStage->setClearMask(_camera->getClearMask()); #if 1 diff --git a/src/osgWrappers/osg/Camera.cpp b/src/osgWrappers/osg/Camera.cpp index faf6f7f2e..f8b4ef10e 100644 --- a/src/osgWrappers/osg/Camera.cpp +++ b/src/osgWrappers/osg/Camera.cpp @@ -184,16 +184,6 @@ BEGIN_OBJECT_REFLECTOR(osg::Camera) __C5_osg_DisplaySettings_P1__getDisplaySettings, "Set the DsplaySettings object associated with this view. ", ""); - I_Method1(void, setClearColor, IN, const osg::Vec4 &, color, - Properties::NON_VIRTUAL, - __void__setClearColor__C5_Vec4_R1, - "Sets the clear color. ", - ""); - I_Method0(const osg::Vec4 &, getClearColor, - Properties::NON_VIRTUAL, - __C5_Vec4_R1__getClearColor, - "Returns the clear color. ", - ""); I_Method1(void, setClearMask, IN, GLbitfield, mask, Properties::NON_VIRTUAL, __void__setClearMask__GLbitfield, @@ -204,6 +194,46 @@ BEGIN_OBJECT_REFLECTOR(osg::Camera) __GLbitfield__getClearMask, "Get the clear mask. ", ""); + I_Method1(void, setClearColor, IN, const osg::Vec4 &, color, + Properties::NON_VIRTUAL, + __void__setClearColor__C5_osg_Vec4_R1, + "Set the clear color used in glClearColor(. ", + ".). glClearColor is only called if mask & GL_COLOR_BUFFER_BIT is true "); + I_Method0(const osg::Vec4 &, getClearColor, + Properties::NON_VIRTUAL, + __C5_osg_Vec4_R1__getClearColor, + "Get the clear color. ", + ""); + I_Method1(void, setClearAccum, IN, const osg::Vec4 &, color, + Properties::NON_VIRTUAL, + __void__setClearAccum__C5_osg_Vec4_R1, + "Set the clear accum used in glClearAccum(. ", + ".). glClearAcumm is only called if mask & GL_ACCUM_BUFFER_BIT is true. "); + I_Method0(const osg::Vec4 &, getClearAccum, + Properties::NON_VIRTUAL, + __C5_osg_Vec4_R1__getClearAccum, + "Get the clear accum value. ", + ""); + I_Method1(void, setClearDepth, IN, double, depth, + Properties::NON_VIRTUAL, + __void__setClearDepth__double, + "Set the clear depth used in glClearDepth(. ", + ".). Defaults to 1.0 glClearDepth is only called if mask & GL_DEPTH_BUFFER_BIT is true. "); + I_Method0(double, getClearDepth, + Properties::NON_VIRTUAL, + __double__getClearDepth, + "Get the clear depth value. ", + ""); + I_Method1(void, setClearStencil, IN, int, stencil, + Properties::NON_VIRTUAL, + __void__setClearStencil__int, + "Set the clear stencil value used in glClearStencil(). ", + "Defaults to 0; glClearStencil is only called if mask & GL_STENCIL_BUFFER_BIT is true "); + I_Method0(int, getClearStencil, + Properties::NON_VIRTUAL, + __int__getClearStencil, + "Get the clear stencil value. ", + ""); I_Method1(void, setColorMask, IN, osg::ColorMask *, colorMask, Properties::NON_VIRTUAL, __void__setColorMask__osg_ColorMask_P1, @@ -608,12 +638,21 @@ BEGIN_OBJECT_REFLECTOR(osg::Camera) I_SimpleProperty(osg::OperationThread *, CameraThread, __OperationThread_P1__getCameraThread, __void__setCameraThread__OperationThread_P1); + I_SimpleProperty(const osg::Vec4 &, ClearAccum, + __C5_osg_Vec4_R1__getClearAccum, + __void__setClearAccum__C5_osg_Vec4_R1); I_SimpleProperty(const osg::Vec4 &, ClearColor, - __C5_Vec4_R1__getClearColor, - __void__setClearColor__C5_Vec4_R1); + __C5_osg_Vec4_R1__getClearColor, + __void__setClearColor__C5_osg_Vec4_R1); + I_SimpleProperty(double, ClearDepth, + __double__getClearDepth, + __void__setClearDepth__double); I_SimpleProperty(GLbitfield, ClearMask, __GLbitfield__getClearMask, __void__setClearMask__GLbitfield); + I_SimpleProperty(int, ClearStencil, + __int__getClearStencil, + __void__setClearStencil__int); I_SimpleProperty(osg::ColorMask *, ColorMask, __ColorMask_P1__getColorMask, __void__setColorMask__osg_ColorMask_P1);