root/OpenSceneGraph/trunk/include/osg/ColorMask @ 13041

Revision 13041, 3.0 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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_COLORMASK
15#define OSG_COLORMASK 1
16
17#include <osg/Export>
18#include <osg/StateAttribute>
19
20namespace osg {
21
22/** Encapsulates OpenGL glColorMaskFunc/Op/Mask functions.
23*/
24class OSG_EXPORT ColorMask : public StateAttribute
25{
26    public :
27
28
29        ColorMask();
30
31        ColorMask(bool red,bool green,bool blue,bool alpha):
32            _red(red),
33            _green(green),
34            _blue(blue),
35            _alpha(alpha) {}
36
37
38        /** Copy constructor using CopyOp to manage deep vs shallow copy. */
39        ColorMask(const ColorMask& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
40            StateAttribute(cm,copyop),
41            _red(cm._red),
42            _green(cm._green),
43            _blue(cm._blue),
44            _alpha(cm._alpha) {}
45
46        META_StateAttribute(osg, ColorMask, COLORMASK);
47
48        /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
49        virtual int compare(const StateAttribute& sa) const
50        {
51            // Check for equal types, then create the rhs variable
52            // used by the COMPARE_StateAttribute_Parameter macros below.
53            COMPARE_StateAttribute_Types(ColorMask,sa)
54
55            // Compare each parameter in turn against the rhs.
56            COMPARE_StateAttribute_Parameter(_red)
57            COMPARE_StateAttribute_Parameter(_green)
58            COMPARE_StateAttribute_Parameter(_blue)
59            COMPARE_StateAttribute_Parameter(_alpha)
60
61            return 0; // Passed all the above comparison macros, so must be equal.
62        }
63
64        inline void setMask(bool red,bool green,bool blue,bool alpha)
65        {
66            _red = red;
67            _green = green;
68            _blue = blue;
69            _alpha = alpha;
70
71        }
72
73        inline void setRedMask(bool mask) { _red=mask; }
74        inline bool getRedMask() const { return _red; }
75
76        inline void setGreenMask(bool mask) { _green=mask; }
77        inline bool getGreenMask() const { return _green; }
78
79        inline void setBlueMask(bool mask) { _blue=mask; }
80        inline bool getBlueMask() const { return _blue; }
81
82        inline void setAlphaMask(bool mask) { _alpha=mask; }
83        inline bool getAlphaMask() const { return _alpha; }
84
85        virtual void apply(State& state) const;
86
87    protected:
88
89        virtual ~ColorMask();
90
91        bool                _red;
92        bool                _green;
93        bool                _blue;
94        bool                _alpha;
95
96};
97
98}
99
100#endif
Note: See TracBrowser for help on using the browser.