openscenegraph
ClearNode
Go to the documentation of this file.
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
14#ifndef OSG_CLEARNODE
15#define OSG_CLEARNODE 1
16
17#include <osg/Group>
18#include <osg/Vec4>
19
20namespace osg {
21
22/** A Group node for clearing the color and depth buffers. Use setClearColor
23 * to change the clear color, and setRequiresClear to disable/enable the call
24 * clearing. You might want to disable clearing if you perform your clear by
25 * drawing fullscreen geometry. If you do this, add child nodes to perform
26 * such drawing. The default StateSet associated with this node places
27 * children in render bin -1 to ensure that children are rendered prior to
28 * the rest of the scene graph.
29*/
30class OSG_EXPORT ClearNode : public Group
31{
32 public :
33
34 ClearNode();
35
36 ClearNode(const ClearNode& cs, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
37 Group(cs,copyop),
38 _requiresClear(cs._requiresClear),
39 _clearColor(cs._clearColor),
40 _clearMask(cs._clearMask) {}
41
42
43 META_Node(osg, ClearNode);
44
45 /** Enable/disable clearing via glClear. */
46 inline void setRequiresClear(bool requiresClear) { _requiresClear = requiresClear; }
47
48 /** Gets whether clearing is enabled or disabled. */
49 inline bool getRequiresClear() const { return _requiresClear; }
50
51 /** Sets the clear color. */
52 inline void setClearColor(const Vec4& color) { _clearColor = color; }
53
54 /** Returns the clear color. */
55 inline const Vec4& getClearColor() const { return _clearColor; }
56
57 /** Set the clear mask used in glClear(..).
58 * Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */
59 inline void setClearMask(GLbitfield mask) { _clearMask = mask; }
60
61 /** Get the clear mask.*/
62 inline GLbitfield getClearMask() const { return _clearMask; }
63
64 protected :
65
66 virtual ~ClearNode() {}
67
68 bool _requiresClear;
69 Vec4 _clearColor;
70 GLbitfield _clearMask;
71};
72
73}
74
75#endif