AlphaFunc
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* 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
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_ALPHAFUNC
#define OSG_ALPHAFUNC 1
#include <osg/StateAttribute>
namespace osg {
class OSG_EXPORT AlphaFunc : public StateAttribute
{
public :
enum ComparisonFunction {
NEVER = GL_NEVER,
LESS = GL_LESS,
EQUAL = GL_EQUAL,
LEQUAL = GL_LEQUAL,
GREATER = GL_GREATER,
NOTEQUAL = GL_NOTEQUAL,
GEQUAL = GL_GEQUAL,
ALWAYS = GL_ALWAYS
};
AlphaFunc();
AlphaFunc(ComparisonFunction func,float ref):
_comparisonFunc(func),
_referenceValue(ref) {}
AlphaFunc(const AlphaFunc& af,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
StateAttribute(af,copyop),
_comparisonFunc(af._comparisonFunc),
_referenceValue(af._referenceValue) {}
META_StateAttribute(osg, AlphaFunc,ALPHAFUNC);
virtual int compare(const StateAttribute& sa) const
{
// Check for equal types, then create the rhs variable
// used by the COMPARE_StateAttribute_Parameter macros below.
COMPARE_StateAttribute_Types(AlphaFunc,sa)
// Compare each parameter in turn against the rhs.
COMPARE_StateAttribute_Parameter(_comparisonFunc)
COMPARE_StateAttribute_Parameter(_referenceValue)
return 0; // Passed all the above comparison macros, so must be equal.
}
virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
{
usage.usesMode(GL_ALPHA_TEST);
return true;
}
inline void setFunction(ComparisonFunction func,float ref)
{
_comparisonFunc = func;
_referenceValue = ref;
}
inline void setFunction(ComparisonFunction func) { _comparisonFunc=func; }
inline ComparisonFunction getFunction() const { return _comparisonFunc; }
inline void setReferenceValue(float value) { _referenceValue=value; }
inline float getReferenceValue() const { return _referenceValue; }
virtual void apply(State& state) const;
protected:
virtual ~AlphaFunc();
ComparisonFunction _comparisonFunc;
float _referenceValue;
};
}
#endif
GL_ALPHA_TEST
#define GL_ALPHA_TEST
Definition GLDefines:674
StateAttribute
COMPARE_StateAttribute_Parameter
#define COMPARE_StateAttribute_Parameter(parameter)
Definition StateAttribute:69
COMPARE_StateAttribute_Types
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
Definition StateAttribute:57
osg::AlphaFunc::AlphaFunc
AlphaFunc(const AlphaFunc &af, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition AlphaFunc:46
osg::AlphaFunc::compare
virtual int compare(const StateAttribute &sa) const
Definition AlphaFunc:54
osg::AlphaFunc::getModeUsage
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition AlphaFunc:67
osg::AlphaFunc::_comparisonFunc
ComparisonFunction _comparisonFunc
Definition AlphaFunc:91
osg::AlphaFunc::~AlphaFunc
virtual ~AlphaFunc()
osg::AlphaFunc::ComparisonFunction
ComparisonFunction
Definition AlphaFunc:27
osg::AlphaFunc::LEQUAL
@ LEQUAL
Definition AlphaFunc:31
osg::AlphaFunc::GEQUAL
@ GEQUAL
Definition AlphaFunc:34
osg::AlphaFunc::NOTEQUAL
@ NOTEQUAL
Definition AlphaFunc:33
osg::AlphaFunc::ALWAYS
@ ALWAYS
Definition AlphaFunc:35
osg::AlphaFunc::NEVER
@ NEVER
Definition AlphaFunc:28
osg::AlphaFunc::EQUAL
@ EQUAL
Definition AlphaFunc:30
osg::AlphaFunc::GREATER
@ GREATER
Definition AlphaFunc:32
osg::AlphaFunc::LESS
@ LESS
Definition AlphaFunc:29
osg::AlphaFunc::apply
virtual void apply(State &state) const
osg::AlphaFunc::AlphaFunc
AlphaFunc()
osg::AlphaFunc::setReferenceValue
void setReferenceValue(float value)
Definition AlphaFunc:82
osg::AlphaFunc::setFunction
void setFunction(ComparisonFunction func)
Definition AlphaFunc:79
osg::AlphaFunc::_referenceValue
float _referenceValue
Definition AlphaFunc:92
osg::AlphaFunc::getFunction
ComparisonFunction getFunction() const
Definition AlphaFunc:80
osg::AlphaFunc::setFunction
void setFunction(ComparisonFunction func, float ref)
Definition AlphaFunc:73
osg::AlphaFunc::getReferenceValue
float getReferenceValue() const
Definition AlphaFunc:83
osg::AlphaFunc::META_StateAttribute
META_StateAttribute(osg, AlphaFunc, ALPHAFUNC)
osg::AlphaFunc::AlphaFunc
AlphaFunc(ComparisonFunction func, float ref)
Definition AlphaFunc:41
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Referenced::ref
int ref() const
Definition Referenced:161
osg::StateAttribute::StateAttribute
StateAttribute()
osg::StateAttribute::ALPHAFUNC
@ ALPHAFUNC
Definition StateAttribute:130
osg::State
Definition State:80
osg
Definition AlphaFunc:19
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39
osg::StateAttribute::ModeUsage
Definition StateAttribute:308
osg::StateAttribute::ModeUsage::usesMode
virtual void usesMode(GLMode mode)=0