OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Depth.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_DEPTH
15 #define OSG_DEPTH 1
16 
17 #include <osg/StateAttribute>
18 
19 namespace osg {
20 
24 {
25  public :
26 
27 
28  enum Function
29  {
30  NEVER = GL_NEVER,
31  LESS = GL_LESS,
32  EQUAL = GL_EQUAL,
33  LEQUAL = GL_LEQUAL,
34  GREATER = GL_GREATER,
35  NOTEQUAL = GL_NOTEQUAL,
36  GEQUAL = GL_GEQUAL,
37  ALWAYS = GL_ALWAYS
38  };
39 
40 
41  Depth(Function func=LESS,double zNear=0.0, double zFar=1.0,bool writeMask=true);
42 
44  Depth(const Depth& dp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
45  StateAttribute(dp,copyop),
46  _func(dp._func),
47  _zNear(dp._zNear),
48  _zFar(dp._zFar),
49  _depthWriteMask(dp._depthWriteMask) {}
50 
51 
52  META_StateAttribute(osg, Depth, DEPTH);
53 
55  virtual int compare(const StateAttribute& sa) const
56  {
57  // check the types are equal and then create the rhs variable
58  // used by the COMPARE_StateAttribute_Parameter macros below.
60 
61  // compare each parameter in turn against the rhs.
63  COMPARE_StateAttribute_Parameter(_depthWriteMask)
66 
67  return 0; // passed all the above comparison macros, must be equal.
68  }
69 
70  virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
71  {
72  usage.usesMode(GL_DEPTH_TEST);
73  return true;
74  }
75 
76  inline void setFunction(Function func) { _func = func; }
77  inline Function getFunction() const { return _func; }
78 
79 
80  inline void setRange(double zNear, double zFar)
81  {
82  _zNear = zNear;
83  _zFar = zFar;
84  }
85 
86  inline void setZNear(double zNear) { _zNear=zNear; }
87  inline double getZNear() const { return _zNear; }
88 
89  inline void setZFar(double zFar) { _zFar=zFar; }
90  inline double getZFar() const { return _zFar; }
91 
92  inline void setWriteMask(bool mask) { _depthWriteMask = mask; }
93  inline bool getWriteMask() const { return _depthWriteMask; }
94 
95 
96  virtual void apply(State& state) const;
97 
98  protected:
99 
100  virtual ~Depth();
101 
103 
104  double _zNear;
105  double _zFar;
106 
108 };
109 
110 }
111 
112 #endif
#define OSG_EXPORT
Definition: Export.h:43
Depth(const Depth &dp, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition: Depth.h:44
double getZFar() const
Definition: Depth.h:90
double getZNear() const
Definition: Depth.h:87
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
Function
Definition: Depth.h:28
bool _depthWriteMask
Definition: Depth.h:107
Function _func
Definition: Depth.h:102
void setRange(double zNear, double zFar)
Definition: Depth.h:80
virtual void usesMode(GLMode mode)=0
void setZFar(double zFar)
Definition: Depth.h:89
virtual int compare(const StateAttribute &sa) const
Definition: Depth.h:55
bool getWriteMask() const
Definition: Depth.h:93
double _zFar
Definition: Depth.h:105
void setWriteMask(bool mask)
Definition: Depth.h:92
void setZNear(double zNear)
Definition: Depth.h:86
Function getFunction() const
Definition: Depth.h:77
void setFunction(Function func)
Definition: Depth.h:76
#define META_StateAttribute(library, name, type)
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition: Depth.h:70
Definition: AlphaFunc.h:19
#define COMPARE_StateAttribute_Parameter(parameter)
double _zNear
Definition: Depth.h:104