openscenegraph
AlphaFunc
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_ALPHAFUNC
15#define OSG_ALPHAFUNC 1
16
17#include <osg/StateAttribute>
18
19namespace osg {
20
24{
25 public :
26
28 NEVER = GL_NEVER,
29 LESS = GL_LESS,
30 EQUAL = GL_EQUAL,
31 LEQUAL = GL_LEQUAL,
32 GREATER = GL_GREATER,
33 NOTEQUAL = GL_NOTEQUAL,
34 GEQUAL = GL_GEQUAL,
35 ALWAYS = GL_ALWAYS
36 };
37
38
40
42 _comparisonFunc(func),
43 _referenceValue(ref) {}
44
46 AlphaFunc(const AlphaFunc& af,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
47 StateAttribute(af,copyop),
48 _comparisonFunc(af._comparisonFunc),
49 _referenceValue(af._referenceValue) {}
50
52
54 virtual int compare(const StateAttribute& sa) const
55 {
56 // Check for equal types, then create the rhs variable
57 // used by the COMPARE_StateAttribute_Parameter macros below.
59
60 // Compare each parameter in turn against the rhs.
63
64 return 0; // Passed all the above comparison macros, so must be equal.
65 }
66
67 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
68 {
70 return true;
71 }
72
73 inline void setFunction(ComparisonFunction func,float ref)
74 {
75 _comparisonFunc = func;
76 _referenceValue = ref;
77 }
78
79 inline void setFunction(ComparisonFunction func) { _comparisonFunc=func; }
80 inline ComparisonFunction getFunction() const { return _comparisonFunc; }
81
82 inline void setReferenceValue(float value) { _referenceValue=value; }
83 inline float getReferenceValue() const { return _referenceValue; }
84
85 virtual void apply(State& state) const;
86
87 protected:
88
89 virtual ~AlphaFunc();
90
93
94};
95
96}
97
98#endif
#define GL_ALPHA_TEST
Definition GLDefines:674
#define COMPARE_StateAttribute_Parameter(parameter)
Definition StateAttribute:69
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
Definition StateAttribute:57
Definition AlphaFunc:24
AlphaFunc(const AlphaFunc &af, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition AlphaFunc:46
virtual int compare(const StateAttribute &sa) const
Definition AlphaFunc:54
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition AlphaFunc:67
ComparisonFunction _comparisonFunc
Definition AlphaFunc:91
virtual ~AlphaFunc()
ComparisonFunction
Definition AlphaFunc:27
virtual void apply(State &state) const
void setReferenceValue(float value)
Definition AlphaFunc:82
void setFunction(ComparisonFunction func)
Definition AlphaFunc:79
float _referenceValue
Definition AlphaFunc:92
ComparisonFunction getFunction() const
Definition AlphaFunc:80
void setFunction(ComparisonFunction func, float ref)
Definition AlphaFunc:73
float getReferenceValue() const
Definition AlphaFunc:83
META_StateAttribute(osg, AlphaFunc, ALPHAFUNC)
AlphaFunc(ComparisonFunction func, float ref)
Definition AlphaFunc:41
Definition CopyOp:41
Definition StateAttribute:77
Definition State:80
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
@ ALWAYS
Definition Notify:31
#define OSG_EXPORT
Definition osg/Export:39
Definition StateAttribute:308
virtual void usesMode(GLMode mode)=0