openscenegraph
PolygonOffset
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
24namespace osg {
25
28{
29 public :
30
32
33 PolygonOffset(float factor, float units);
34
36 PolygonOffset(const PolygonOffset& po,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
37 StateAttribute(po,copyop),
38 _factor(po._factor),
39 _units(po._units) {}
40
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
83
87
88 protected :
89
90 virtual ~PolygonOffset();
91
92 float _factor;
93 float _units;
94
95};
96
97}
98
99#endif
#define GL_POLYGON_OFFSET_LINE
Definition PolygonOffset:20
#define GL_POLYGON_OFFSET_POINT
Definition PolygonOffset:21
#define COMPARE_StateAttribute_Parameter(parameter)
Definition StateAttribute:69
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
Definition StateAttribute:57
Definition CopyOp:41
Definition PolygonOffset:28
virtual int compare(const StateAttribute &sa) const
Definition PolygonOffset:44
float _units
Definition PolygonOffset:93
static bool areFactorAndUnitsMultipliersSet()
virtual ~PolygonOffset()
static float getFactorMultiplier()
static float getUnitsMultiplier()
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition PolygonOffset:57
PolygonOffset(float factor, float units)
void setUnits(float units)
Definition PolygonOffset:70
void setFactor(float factor)
Definition PolygonOffset:67
META_StateAttribute(osg, PolygonOffset, POLYGONOFFSET)
static void setFactorMultiplier(float multiplier)
float getFactor() const
Definition PolygonOffset:68
PolygonOffset(const PolygonOffset &po, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition PolygonOffset:36
float getUnits() const
Definition PolygonOffset:71
float _factor
Definition PolygonOffset:92
virtual void apply(State &state) const
static void setFactorAndUnitsMultipliersUsingBestGuessForDriver()
static void setUnitsMultiplier(float multiplier)
Definition StateAttribute:77
Definition State:80
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSG_EXPORT
Definition osg/Export:39
Definition StateAttribute:308
virtual void usesMode(GLMode mode)=0