ClearNode 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSG_CLEARNODE
  14. #define OSG_CLEARNODE 1
  15. #include <osg/Group>
  16. #include <osg/Vec4>
  17. namespace osg {
  18. /** A Group node for clearing the color and depth buffers. Use setClearColor
  19. * to change the clear color, and setRequiresClear to disable/enable the call
  20. * clearing. You might want to disable clearing if you perform your clear by
  21. * drawing fullscreen geometry. If you do this, add child nodes to perform
  22. * such drawing. The default StateSet associated with this node places
  23. * children in render bin -1 to ensure that children are rendered prior to
  24. * the rest of the scene graph.
  25. */
  26. class OSG_EXPORT ClearNode : public Group
  27. {
  28. public :
  29. ClearNode();
  30. ClearNode(const ClearNode& cs, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  31. Group(cs,copyop),
  32. _requiresClear(cs._requiresClear),
  33. _clearColor(cs._clearColor),
  34. _clearMask(cs._clearMask) {}
  35. META_Node(osg, ClearNode);
  36. /** Enable/disable clearing via glClear. */
  37. inline void setRequiresClear(bool requiresClear) { _requiresClear = requiresClear; }
  38. /** Gets whether clearing is enabled or disabled. */
  39. inline bool getRequiresClear() const { return _requiresClear; }
  40. /** Sets the clear color. */
  41. inline void setClearColor(const Vec4& color) { _clearColor = color; }
  42. /** Returns the clear color. */
  43. inline const Vec4& getClearColor() const { return _clearColor; }
  44. /** Set the clear mask used in glClear(..).
  45. * Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */
  46. inline void setClearMask(GLbitfield mask) { _clearMask = mask; }
  47. /** Get the clear mask.*/
  48. inline GLbitfield getClearMask() const { return _clearMask; }
  49. protected :
  50. virtual ~ClearNode() {}
  51. bool _requiresClear;
  52. Vec4 _clearColor;
  53. GLbitfield _clearMask;
  54. };
  55. }
  56. #endif