OpenSceneGraph 3.6.5
Fog
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_FOG
15#define OSG_FOG 1
16
17#include <osg/StateAttribute>
18#include <osg/Vec4>
19
20#ifndef GL_FOG_DISTANCE_MODE_NV
21 #define GL_FOG_DISTANCE_MODE_NV 0x855A
22#endif
23#ifndef GL_EYE_PLANE_ABSOLUTE_NV
24 #define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
25#endif
26#ifndef GL_EYE_RADIAL_NV
27 #define GL_EYE_RADIAL_NV 0x855B
28#endif
29
30
31#ifndef GL_FOG_COORDINATE
32 #define GL_FOG_COORDINATE 0x8451
33#endif
34#ifndef GL_FRAGMENT_DEPTH
35 #define GL_FRAGMENT_DEPTH 0x8452
36#endif
37
38#ifndef GL_FOG
39 #define GL_FOG 0x0B60
40 #define GL_EXP 0x0800
41 #define GL_EXP2 0x0801
42#endif
43
44#ifndef GL_FOG_HINT
45 #define GL_FOG_HINT 0x0C54
46#endif
47
48namespace osg {
49
50
53{
54 public :
55
56 Fog();
57
59 Fog(const Fog& fog,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
60 StateAttribute(fog,copyop),
61 _mode(fog._mode),
62 _density(fog._density),
63 _start(fog._start),
64 _end(fog._end),
65 _color(fog._color),
68
70
72 virtual int compare(const StateAttribute& sa) const
73 {
74 // check the types are equal and then create the rhs variable
75 // used by the COMPARE_StateAttribute_Parameter macros below.
77
78 // compare each parameter in turn against the rhs.
86
87 return 0; // passed all the above comparison macros, must be equal.
88 }
89
90 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
91 {
92 usage.usesMode(GL_FOG);
93 return true;
94 }
95
96 enum Mode {
97 LINEAR = GL_LINEAR,
100 };
101
102 inline void setMode( Mode mode ) { _mode = mode; }
103 inline Mode getMode() const { return _mode; }
104
105 inline void setDensity( float density ) { _density = density; }
106 inline float getDensity() const { return _density; }
107
108 inline void setStart( float start ) { _start = start; }
109 inline float getStart() const { return _start; }
110
111 inline void setEnd( float end ) { _end = end; }
112 inline float getEnd() const { return _end; }
113
114 inline void setColor( const Vec4 &color ) { _color = color; }
115 inline const Vec4& getColor() const { return _color; }
116
117 inline void setUseRadialFog( bool useRadialFog ) { _useRadialFog = useRadialFog; }
118 inline bool getUseRadialFog() const { return _useRadialFog; }
119
125
126 inline void setFogCoordinateSource(GLint source) { _fogCoordinateSource = source; }
127 inline GLint getFogCoordinateSource() const { return _fogCoordinateSource; }
128
129 virtual void apply(State& state) const;
130
131 protected :
132
133 virtual ~Fog();
134
136 float _density;
137 float _start;
138 float _end;
142};
143
144}
145
146#endif
#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
#define GL_EXP
Definition Fog:40
#define GL_EXP2
Definition Fog:41
#define GL_FOG
Definition Fog:39
#define GL_FOG_COORDINATE
Definition Fog:32
#define GL_FRAGMENT_DEPTH
Definition Fog:35
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Vec4f Vec4
Definition Vec4:21
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
Vec4 _color
Definition Fog:139
GLint getFogCoordinateSource() const
Definition Fog:127
float _end
Definition Fog:138
bool getUseRadialFog() const
Definition Fog:118
void setFogCoordinateSource(GLint source)
Definition Fog:126
void setEnd(float end)
Definition Fog:111
FogCoordinateSource
Definition Fog:121
@ FRAGMENT_DEPTH
Definition Fog:123
@ FOG_COORDINATE
Definition Fog:122
float getDensity() const
Definition Fog:106
float _density
Definition Fog:136
const Vec4 & getColor() const
Definition Fog:115
Mode _mode
Definition Fog:135
void setDensity(float density)
Definition Fog:105
float getEnd() const
Definition Fog:112
void setUseRadialFog(bool useRadialFog)
Definition Fog:117
virtual int compare(const StateAttribute &sa) const
return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
Definition Fog:72
virtual ~Fog()
float getStart() const
Definition Fog:109
bool _useRadialFog
Definition Fog:141
float _start
Definition Fog:137
Mode getMode() const
Definition Fog:103
void setStart(float start)
Definition Fog:108
void setMode(Mode mode)
Definition Fog:102
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Return the modes associated with this StateAttribute.
Definition Fog:90
GLint _fogCoordinateSource
Definition Fog:140
META_StateAttribute(osg, Fog, FOG)
Fog(const Fog &fog, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
Definition Fog:59
Mode
Definition Fog:96
@ EXP2
Definition Fog:99
@ EXP
Definition Fog:98
@ LINEAR
Definition Fog:97
void setColor(const Vec4 &color)
Definition Fog:114
virtual void apply(State &state) const
apply the OpenGL state attributes.
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
@ FOG
Definition StateAttribute:134
Definition StateAttribute:308
virtual void usesMode(GLMode mode)=0
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.