OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ColorMask.h
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_COLORMASK
15 #define OSG_COLORMASK 1
16 
17 #include <osg/Export>
18 #include <osg/StateAttribute>
19 
20 namespace osg {
21 
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 
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 
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.
54 
55  // Compare each parameter in turn against the rhs.
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
#define OSG_EXPORT
Definition: Export.h:43
bool getAlphaMask() const
Definition: ColorMask.h:83
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
bool getRedMask() const
Definition: ColorMask.h:74
void setBlueMask(bool mask)
Definition: ColorMask.h:79
ColorMask(bool red, bool green, bool blue, bool alpha)
Definition: ColorMask.h:31
bool getBlueMask() const
Definition: ColorMask.h:80
void setAlphaMask(bool mask)
Definition: ColorMask.h:82
void setRedMask(bool mask)
Definition: ColorMask.h:73
void setMask(bool red, bool green, bool blue, bool alpha)
Definition: ColorMask.h:64
ColorMask(const ColorMask &cm, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition: ColorMask.h:39
void setGreenMask(bool mask)
Definition: ColorMask.h:76
bool getGreenMask() const
Definition: ColorMask.h:77
#define META_StateAttribute(library, name, type)
virtual int compare(const StateAttribute &sa) const
Definition: ColorMask.h:49
Definition: AlphaFunc.h:19
#define COMPARE_StateAttribute_Parameter(parameter)