OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PolygonOffset.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_POLYGONOFFSET
15 #define OSG_POLYGONOFFSET 1
16 
17 #include <osg/StateAttribute>
18 
19 #ifndef GL_POLYGON_OFFSET_LINE
20  #define GL_POLYGON_OFFSET_LINE 0x2A02
21  #define GL_POLYGON_OFFSET_POINT 0x2A01
22 #endif
23 
24 namespace osg {
25 
28 {
29  public :
30 
31  PolygonOffset();
32 
33  PolygonOffset(float factor, float units);
34 
37  StateAttribute(po,copyop),
38  _factor(po._factor),
39  _units(po._units) {}
40 
41  META_StateAttribute(osg, PolygonOffset, POLYGONOFFSET);
42 
44  virtual int compare(const StateAttribute& sa) const
45  {
46  // check the types are equal and then create the rhs variable
47  // used by the COMPARE_StateAttribute_Parameter macros below.
49 
50  // compare each parameter in turn against the rhs.
53 
54  return 0; // passed all the above comparison macros, must be equal.
55  }
56 
57  virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
58  {
59  usage.usesMode(GL_POLYGON_OFFSET_FILL);
60 #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
63 #endif
64  return true;
65  }
66 
67  inline void setFactor(float factor) { _factor = factor; }
68  inline float getFactor() const { return _factor; }
69 
70  inline void setUnits(float units) { _units = units; }
71  inline float getUnits() const { return _units; }
72 
73  virtual void apply(State& state) const;
74 
75 
76  static void setFactorMultiplier(float multiplier);
77  static float getFactorMultiplier();
78 
79  static void setUnitsMultiplier(float multiplier);
80  static float getUnitsMultiplier();
81 
82  static bool areFactorAndUnitsMultipliersSet();
83 
86  static void setFactorAndUnitsMultipliersUsingBestGuessForDriver();
87 
88  protected :
89 
90  virtual ~PolygonOffset();
91 
92  float _factor;
93  float _units;
94 
95 };
96 
97 }
98 
99 #endif
#define OSG_EXPORT
Definition: Export.h:43
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
virtual int compare(const StateAttribute &sa) const
Definition: PolygonOffset.h:44
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition: PolygonOffset.h:57
void setFactor(float factor)
Definition: PolygonOffset.h:67
float getFactor() const
Definition: PolygonOffset.h:68
virtual void usesMode(GLMode mode)=0
#define GL_POLYGON_OFFSET_LINE
Definition: PolygonOffset.h:20
void setUnits(float units)
Definition: PolygonOffset.h:70
#define META_StateAttribute(library, name, type)
#define GL_POLYGON_OFFSET_POINT
Definition: PolygonOffset.h:21
float getUnits() const
Definition: PolygonOffset.h:71
Definition: AlphaFunc.h:19
PolygonOffset(const PolygonOffset &po, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition: PolygonOffset.h:36
#define COMPARE_StateAttribute_Parameter(parameter)