OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BlendColor.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_BLENDCOLOR
15 #define OSG_BLENDCOLOR 1
16 
17 #include <osg/GL>
18 #include <osg/StateAttribute>
19 #include <osg/ref_ptr>
20 #include <osg/Vec4>
21 
22 
23 namespace osg {
24 
27 {
28  public :
29 
30  BlendColor();
31 
32  BlendColor(const osg::Vec4& constantColor);
33 
35  BlendColor(const BlendColor& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
36  StateAttribute(trans,copyop),
37  _constantColor(trans._constantColor) {}
38 
39  META_StateAttribute(osg, BlendColor,BLENDCOLOR);
40 
42  virtual int compare(const StateAttribute& sa) const
43  {
44  // Check for equal types, then create the rhs variable
45  // used by the COMPARE_StateAttribute_Parameter macros below.
47 
48  // Compare each parameter in turn against the rhs.
49  COMPARE_StateAttribute_Parameter(_constantColor)
50 
51  return 0; // Passed all the above comparison macros, so must be equal.
52  }
53 
54  virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
55  {
56  usage.usesMode(GL_BLEND);
57  return true;
58  }
59 
60  void setConstantColor(const osg::Vec4& color) { _constantColor = color; }
61 
62  inline osg::Vec4& getConstantColor() { return _constantColor; }
63 
64  inline const osg::Vec4& getConstantColor() const { return _constantColor; }
65 
66  virtual void apply(State& state) const;
67 
68  protected :
69 
70  virtual ~BlendColor();
71 
73 };
74 
75 }
76 
77 #endif
#define OSG_EXPORT
Definition: Export.h:43
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
virtual int compare(const StateAttribute &sa) const
Definition: BlendColor.h:42
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition: BlendColor.h:54
osg::Vec4 & getConstantColor()
Definition: BlendColor.h:62
const osg::Vec4 & getConstantColor() const
Definition: BlendColor.h:64
virtual void usesMode(GLMode mode)=0
void setConstantColor(const osg::Vec4 &color)
Definition: BlendColor.h:60
BlendColor(const BlendColor &trans, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition: BlendColor.h:35
#define META_StateAttribute(library, name, type)
Definition: AlphaFunc.h:19
osg::Vec4 _constantColor
Definition: BlendColor.h:72
#define COMPARE_StateAttribute_Parameter(parameter)