Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglFog Class Reference

#include <sglFog.hpp>

Inheritance diagram for sglFog::

sglStatelet sglObject List of all members.

Public Types

enum  ModeEnum {
  eOFF = 0,
  eEXP = GL_EXP,
  eEXP2 = GL_EXP2,
enum  DistanceEqEnum {

Public Methods

 sglFog ()
virtual ~sglFog ()
void setMode (ModeEnum mode)
ModeEnum getMode () const
void setDistanceEquation (DistanceEqEnum eq)
DistanceEqEnum getDistanceEquation () const
void setExtent (float start, float end)
void getExtent (float &start, float &end) const
void setDensity (float density)
float getDensity () const
void setColor (const sglVec4f &color)
void setColor (float r, float g, float b, float a)
const sglVec4f& getColor () const
void apply (sglCurrState *) const
virtual bool getSorted () const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Protected Attributes

ModeEnum m_mode
float m_start
float m_end
float m_density
DistanceEqEnum m_distance_equation
sglVec4f m_color

Detailed Description

This statelet encapsulates the OpenGL glFog*(..) and glEnable(GL_FOG) functions that control OpenGL fog characteristics. With this enabled, objects that are farther from the viewpoint begin to fade into the fog color. This statelet also supports the "eye plane absolute" and "eye radial" modes of the GL_NV_fog_distance extension.


   sglFog *fog = new sglFog;
   fog->setColor(0.f, 0.f, 0.f, 1.0f);
   fog->setExtent(0.f, 100.f);

   if (sgl::s_fog_distance_capable)

Definition at line 60 of file sglFog.hpp.

Member Enumeration Documentation

enum sglFog::ModeEnum

Valid sglFog modes:.

Enumeration values:
eOFF   disable fog (the default).
eEXP   exponential fog.
eEXP2   exponential squared fog.
eLINEAR   linear fog.

Definition at line 64 of file sglFog.hpp.

enum sglFog::DistanceEqEnum

Distance equations for systems with the NVIDIA extensions.

Enumeration values:
eEYE_PLANE_ABSOLUTE   perpendicular distance from the near clip plane.
eEYE_RADIAL   real distance from the view point.

Definition at line 80 of file sglFog.hpp.

Constructor & Destructor Documentation

sglFog::sglFog ( )

Default constructor. Initializes a disabled fog statelet (i.e. no fog).

sglFog::~sglFog ( ) [virtual]

Virtual destructor.

Member Function Documentation

void sglFog::setMode ( ModeEnum mode )

Set the fog mode.

mode   One of {eOFF, eEXP, eEXP2, or eLINEAR}. Default: eOFF

ModeEnum sglFog::getMode ( ) const [inline]

Get the current fog mode.

One of {eOFF, eEXP, eEXP2, or eLINEAR}.

Definition at line 105 of file sglFog.hpp.

void sglFog::setDistanceEquation ( DistanceEqEnum eq )

Set the fog distance calculation equation.


DistanceEqEnum sglFog::getDistanceEquation ( ) const [inline]

Get the current fog distance calc. eq.


Definition at line 116 of file sglFog.hpp.

void sglFog::setExtent ( float start,
float end )

Set the extent of the fog (distances from the viewer). This is used in eLinear mode only. Only values greater than or equal to zero are accepted and end must be greater than start.

start   The closest distance of the fog. Default: 0.
end   The furthest distance of the fog. Default 1.

void sglFog::getExtent ( float & start,
float & end ) const [inline]

Get the linear fog extents.

start   On return contains the near distance.
end   On return contains the far distance.

Definition at line 130 of file sglFog.hpp.

void sglFog::setDensity ( float density )

Set the fog density parameter for exponential modes.

density   Exponent factor in the exponential fog functions. Default: 1

float sglFog::getDensity ( ) const [inline]

Get the density.

The density (i.e. exponent factor) of the fog functions.

Definition at line 142 of file sglFog.hpp.

void sglFog::setColor ( const sglVec4f & color ) [inline]

Set the fog color.

color   Vector containing a 4 component RGBA color. Default: 0, 0, 0, 0.

Definition at line 148 of file sglFog.hpp.

void sglFog::setColor ( float r,
float g,
float b,
float a ) [inline]

Set the fog color using 4 floating point values (from 0...1).

r   Red color component.
g   Green color component.
b   Blue color component.
a   Alpha color component.

Definition at line 156 of file sglFog.hpp.

const sglVec4f & sglFog::getColor ( ) const [inline]

Get the fog color.

A reference to the vector containing the 4 component RGBA color.

Definition at line 161 of file sglFog.hpp.

void sglFog::apply ( sglCurrState * curr_state ) const [virtual]

Apply this state change to the current rendering state.

curr_state   Required for statelets that affect one another. For example the sglTransparency sets up depth mask and blending modes which interact with the sglBlending and sglDepthMask statelets, and the curr_state object is used to resolve these internal issues.

Reimplemented from sglStatelet.

bool sglFog::getSorted ( ) const [inline, virtual]

Query the sorting mode for this statelet.

true if this type of statelet should be sorted by pointer rather than using m_index to index into an array. The defualt implementation is the latter, but if a statelet can take on an inordinate number of states (e.g. a floating point parameter) then true should be returned.

Reimplemented from sglStatelet.

Definition at line 167 of file sglFog.hpp.

virtual void sglFog::printInfo ( ostream & ostrm,
const char * indent_string ) const [virtual]

Output the state of this node to the specified ostream.

ostrm   the ostream to which the output is sent
indent_string   the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglStatelet.

The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:07 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001