2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-09-17 20:04:48 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2003-09-17 20:04:48 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2003-09-17 20:04:48 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-09-17 20:04:48 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OSG_BLENDCOLOR
|
|
|
|
#define OSG_BLENDCOLOR 1
|
|
|
|
|
|
|
|
#include <osg/GL>
|
|
|
|
#include <osg/StateAttribute>
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Vec4>
|
|
|
|
|
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
2004-09-01 16:15:36 +08:00
|
|
|
/** Encapsulates OpenGL blend/transparency state. */
|
2005-04-12 01:14:17 +08:00
|
|
|
class OSG_EXPORT BlendColor : public StateAttribute
|
2003-09-17 20:04:48 +08:00
|
|
|
{
|
|
|
|
public :
|
|
|
|
|
|
|
|
BlendColor();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2006-02-09 20:20:42 +08:00
|
|
|
BlendColor(const osg::Vec4& constantColor);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2003-09-17 20:04:48 +08:00
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
|
|
|
BlendColor(const BlendColor& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
|
|
|
StateAttribute(trans,copyop),
|
|
|
|
_constantColor(trans._constantColor) {}
|
|
|
|
|
|
|
|
META_StateAttribute(osg, BlendColor,BLENDCOLOR);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2004-09-01 16:15:36 +08:00
|
|
|
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
|
2003-09-17 20:04:48 +08:00
|
|
|
virtual int compare(const StateAttribute& sa) const
|
|
|
|
{
|
2004-09-01 16:15:36 +08:00
|
|
|
// Check for equal types, then create the rhs variable
|
2010-10-01 00:57:02 +08:00
|
|
|
// used by the COMPARE_StateAttribute_Parameter macros below.
|
2003-09-17 20:04:48 +08:00
|
|
|
COMPARE_StateAttribute_Types(BlendColor,sa)
|
|
|
|
|
2004-09-01 16:15:36 +08:00
|
|
|
// Compare each parameter in turn against the rhs.
|
2003-09-17 20:04:48 +08:00
|
|
|
COMPARE_StateAttribute_Parameter(_constantColor)
|
|
|
|
|
2004-09-01 16:15:36 +08:00
|
|
|
return 0; // Passed all the above comparison macros, so must be equal.
|
2003-09-17 20:04:48 +08:00
|
|
|
}
|
|
|
|
|
2007-03-06 01:34:36 +08:00
|
|
|
virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
|
2003-09-17 20:04:48 +08:00
|
|
|
{
|
2004-03-03 23:38:22 +08:00
|
|
|
usage.usesMode(GL_BLEND);
|
|
|
|
return true;
|
2003-09-17 20:04:48 +08:00
|
|
|
}
|
|
|
|
|
2003-09-26 05:54:33 +08:00
|
|
|
void setConstantColor(const osg::Vec4& color) { _constantColor = color; }
|
2006-09-19 04:54:48 +08:00
|
|
|
|
|
|
|
inline osg::Vec4& getConstantColor() { return _constantColor; }
|
|
|
|
|
|
|
|
inline const osg::Vec4& getConstantColor() const { return _constantColor; }
|
2003-09-17 20:04:48 +08:00
|
|
|
|
|
|
|
virtual void apply(State& state) const;
|
|
|
|
|
|
|
|
protected :
|
|
|
|
|
|
|
|
virtual ~BlendColor();
|
|
|
|
|
|
|
|
osg::Vec4 _constantColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|