OpenSceneGraph 3.6.5
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
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)
COMPARE_StateAttribute_Parameter macro is a helper for implementing the StatateAtribute::compare(....
Definition StateAttribute:69
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
COMPARE_StateAttribute_Types macro is a helper for implementing the StateAtribute::compare(....
Definition StateAttribute:57
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
virtual int compare(const StateAttribute &sa) const
return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
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
Return the modes associated with this StateAttribute.
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)
Copy constructor using CopyOp to manage deep vs shallow copy.
Definition PolygonOffset:36
float getUnits() const
Definition PolygonOffset:71
float _factor
Definition PolygonOffset:92
virtual void apply(State &state) const
apply the OpenGL state attributes.
static void setFactorAndUnitsMultipliersUsingBestGuessForDriver()
Checks with the OpenGL driver to try and pick multiplier appropriate for the hardware.
static void setUnitsMultiplier(float multiplier)
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
@ POLYGONOFFSET
Definition StateAttribute:128
Definition StateAttribute:308
virtual void usesMode(GLMode mode)=0
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.