Fog
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_FOG
#define OSG_FOG 1
#include <osg/StateAttribute>
#include <osg/Vec4>
#ifndef GL_FOG_DISTANCE_MODE_NV
#define GL_FOG_DISTANCE_MODE_NV 0x855A
#endif
#ifndef GL_EYE_PLANE_ABSOLUTE_NV
#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
#endif
#ifndef GL_EYE_RADIAL_NV
#define GL_EYE_RADIAL_NV 0x855B
#endif
#ifndef GL_FOG_COORDINATE
#define GL_FOG_COORDINATE 0x8451
#endif
#ifndef GL_FRAGMENT_DEPTH
#define GL_FRAGMENT_DEPTH 0x8452
#endif
#ifndef GL_FOG
#define GL_FOG 0x0B60
#define GL_EXP 0x0800
#define GL_EXP2 0x0801
#endif
#ifndef GL_FOG_HINT
#define GL_FOG_HINT 0x0C54
#endif
namespace osg {
class OSG_EXPORT Fog : public StateAttribute
{
public :
Fog();
Fog(const Fog& fog,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
StateAttribute(fog,copyop),
_mode(fog._mode),
_density(fog._density),
_start(fog._start),
_end(fog._end),
_color(fog._color),
_fogCoordinateSource(fog._fogCoordinateSource),
_useRadialFog(fog._useRadialFog) {}
META_StateAttribute(osg, Fog,FOG);
virtual int compare(const StateAttribute& sa) const
{
// check the types are equal and then create the rhs variable
// used by the COMPARE_StateAttribute_Parameter macros below.
COMPARE_StateAttribute_Types(Fog,sa)
// compare each parameter in turn against the rhs.
COMPARE_StateAttribute_Parameter(_mode)
COMPARE_StateAttribute_Parameter(_density)
COMPARE_StateAttribute_Parameter(_start)
COMPARE_StateAttribute_Parameter(_end)
COMPARE_StateAttribute_Parameter(_color)
COMPARE_StateAttribute_Parameter(_fogCoordinateSource)
COMPARE_StateAttribute_Parameter(_useRadialFog)
return 0; // passed all the above comparison macros, must be equal.
}
virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
{
usage.usesMode(GL_FOG);
return true;
}
enum Mode {
LINEAR = GL_LINEAR,
EXP = GL_EXP,
EXP2 = GL_EXP2
};
inline void setMode( Mode mode ) { _mode = mode; }
inline Mode getMode() const { return _mode; }
inline void setDensity( float density ) { _density = density; }
inline float getDensity() const { return _density; }
inline void setStart( float start ) { _start = start; }
inline float getStart() const { return _start; }
inline void setEnd( float end ) { _end = end; }
inline float getEnd() const { return _end; }
inline void setColor( const Vec4 &color ) { _color = color; }
inline const Vec4& getColor() const { return _color; }
inline void setUseRadialFog( bool useRadialFog ) { _useRadialFog = useRadialFog; }
inline bool getUseRadialFog() const { return _useRadialFog; }
enum FogCoordinateSource
{
FOG_COORDINATE = GL_FOG_COORDINATE,
FRAGMENT_DEPTH = GL_FRAGMENT_DEPTH
};
inline void setFogCoordinateSource(GLint source) { _fogCoordinateSource = source; }
inline GLint getFogCoordinateSource() const { return _fogCoordinateSource; }
virtual void apply(State& state) const;
protected :
virtual ~Fog();
Mode _mode;
float _density;
float _start;
float _end;
Vec4 _color;
GLint _fogCoordinateSource;
bool _useRadialFog;
};
}
#endif
GL_EXP
#define GL_EXP
Definition Fog:40
GL_EXP2
#define GL_EXP2
Definition Fog:41
GL_FOG
#define GL_FOG
Definition Fog:39
GL_FOG_COORDINATE
#define GL_FOG_COORDINATE
Definition Fog:32
GL_FRAGMENT_DEPTH
#define GL_FRAGMENT_DEPTH
Definition Fog:35
StateAttribute
COMPARE_StateAttribute_Parameter
#define COMPARE_StateAttribute_Parameter(parameter)
Definition StateAttribute:69
COMPARE_StateAttribute_Types
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
Definition StateAttribute:57
Vec4
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Fog::_color
Vec4 _color
Definition Fog:139
osg::Fog::getFogCoordinateSource
GLint getFogCoordinateSource() const
Definition Fog:127
osg::Fog::_end
float _end
Definition Fog:138
osg::Fog::getUseRadialFog
bool getUseRadialFog() const
Definition Fog:118
osg::Fog::setFogCoordinateSource
void setFogCoordinateSource(GLint source)
Definition Fog:126
osg::Fog::setEnd
void setEnd(float end)
Definition Fog:111
osg::Fog::FogCoordinateSource
FogCoordinateSource
Definition Fog:121
osg::Fog::FRAGMENT_DEPTH
@ FRAGMENT_DEPTH
Definition Fog:123
osg::Fog::FOG_COORDINATE
@ FOG_COORDINATE
Definition Fog:122
osg::Fog::getDensity
float getDensity() const
Definition Fog:106
osg::Fog::_density
float _density
Definition Fog:136
osg::Fog::getColor
const Vec4 & getColor() const
Definition Fog:115
osg::Fog::_mode
Mode _mode
Definition Fog:135
osg::Fog::setDensity
void setDensity(float density)
Definition Fog:105
osg::Fog::getEnd
float getEnd() const
Definition Fog:112
osg::Fog::setUseRadialFog
void setUseRadialFog(bool useRadialFog)
Definition Fog:117
osg::Fog::compare
virtual int compare(const StateAttribute &sa) const
Definition Fog:72
osg::Fog::~Fog
virtual ~Fog()
osg::Fog::getStart
float getStart() const
Definition Fog:109
osg::Fog::_useRadialFog
bool _useRadialFog
Definition Fog:141
osg::Fog::_start
float _start
Definition Fog:137
osg::Fog::getMode
Mode getMode() const
Definition Fog:103
osg::Fog::setStart
void setStart(float start)
Definition Fog:108
osg::Fog::Fog
Fog()
osg::Fog::setMode
void setMode(Mode mode)
Definition Fog:102
osg::Fog::getModeUsage
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition Fog:90
osg::Fog::_fogCoordinateSource
GLint _fogCoordinateSource
Definition Fog:140
osg::Fog::META_StateAttribute
META_StateAttribute(osg, Fog, FOG)
osg::Fog::Fog
Fog(const Fog &fog, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Definition Fog:59
osg::Fog::Mode
Mode
Definition Fog:96
osg::Fog::EXP2
@ EXP2
Definition Fog:99
osg::Fog::EXP
@ EXP
Definition Fog:98
osg::Fog::LINEAR
@ LINEAR
Definition Fog:97
osg::Fog::setColor
void setColor(const Vec4 &color)
Definition Fog:114
osg::Fog::apply
virtual void apply(State &state) const
osg::StateAttribute::StateAttribute
StateAttribute()
osg::StateAttribute::FOG
@ FOG
Definition StateAttribute:134
osg::State
Definition State:80
osg
Definition AlphaFunc:19
osg::Vec4
Vec4f Vec4
Definition Vec4:21
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39
osg::StateAttribute::ModeUsage
Definition StateAttribute:308
osg::StateAttribute::ModeUsage::usesMode
virtual void usesMode(GLMode mode)=0