1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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.
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.
15#define OSG_COLORMASK 1
18#include <osg/StateAttribute>
22/** Encapsulates OpenGL glColorMaskFunc/Op/Mask functions.
24class OSG_EXPORT ColorMask : public StateAttribute
31 ColorMask(bool red,bool green,bool blue,bool alpha):
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),
46 META_StateAttribute(osg, ColorMask, COLORMASK);
48 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
49 virtual int compare(const StateAttribute& sa) const
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)
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)
61 return 0; // Passed all the above comparison macros, so must be equal.
64 inline void setMask(bool red,bool green,bool blue,bool alpha)
73 inline void setRedMask(bool mask) { _red=mask; }
74 inline bool getRedMask() const { return _red; }
76 inline void setGreenMask(bool mask) { _green=mask; }
77 inline bool getGreenMask() const { return _green; }
79 inline void setBlueMask(bool mask) { _blue=mask; }
80 inline bool getBlueMask() const { return _blue; }
82 inline void setAlphaMask(bool mask) { _alpha=mask; }
83 inline bool getAlphaMask() const { return _alpha; }
85 virtual void apply(State& state) const;