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_BLENDCOLOR 1
18#include <osg/StateAttribute>
25/** Encapsulates OpenGL blend/transparency state. */
26class OSG_EXPORT BlendColor : public StateAttribute
32 BlendColor(const osg::Vec4& constantColor);
34 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
35 BlendColor(const BlendColor& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
36 StateAttribute(trans,copyop),
37 _constantColor(trans._constantColor) {}
39 META_StateAttribute(osg, BlendColor,BLENDCOLOR);
41 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
42 virtual int compare(const StateAttribute& sa) const
44 // Check for equal types, then create the rhs variable
45 // used by the COMPARE_StateAttribute_Parameter macros below.
46 COMPARE_StateAttribute_Types(BlendColor,sa)
48 // Compare each parameter in turn against the rhs.
49 COMPARE_StateAttribute_Parameter(_constantColor)
51 return 0; // Passed all the above comparison macros, so must be equal.
54 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
56 usage.usesMode(GL_BLEND);
60 void setConstantColor(const osg::Vec4& color) { _constantColor = color; }
62 inline osg::Vec4& getConstantColor() { return _constantColor; }
64 inline const osg::Vec4& getConstantColor() const { return _constantColor; }
66 virtual void apply(State& state) const;
70 virtual ~BlendColor();
72 osg::Vec4 _constantColor;