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

sglPolygonOffset Class Reference

#include <sglStatelet.hpp>

Inheritance diagram for sglPolygonOffset::

sglStatelet sglObject List of all members.

Public Methods

 sglPolygonOffset (float factor=0, float units=0)
virtual ~sglPolygonOffset ()
void setPolygonOffset (float factor, float units)
void getPolygonOffset (float &factor, float &units) const
bool getPolygonOffsetFlag () const
void apply (sglCurrState *curr_state) const
virtual bool getSorted () const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Detailed Description

This statelet encapsulates OpenGL's glPolygonOffset() and glEnable(GL_POLYGON_OFFSET_*) functions. When enabled the depth value of each fragment is added to a calculated offset according to following formula:
   offset = m * factor + r * units
where (according to the OpenGL Red Book) "m is the maximum depth slope of the polygon and r is the smallest value guaranteed to produce a resolvable difference in the window coordinate depth values." The factor and units are provided by this class. When factor and units are set to zero, that disables the polygon offset. When either is non-zero then polygon offset will be enabled for POINTS, LINES, and FILLed polygon modes.

Note that this statelet enables polygon offset for polygons in fill, line, and point mode.

Example:

   sglPolygonOffset *po = new sglPolygonOffset;  // disabled by default
   po->setPolygonOffset(1.0, 1.0);               // pushes polygons farther.

Definition at line 1917 of file sglStatelet.hpp.


Constructor & Destructor Documentation

sglPolygonOffset::sglPolygonOffset ( float factor = 0,
float units = 0 ) [inline]
 

Constructor (also the default constructor). If both parameters are set to zero then polygon offset is disabled.

Parameters:
factor   The multiplicative factor for the maximum depth slope of the polygon. This can take on any floating point value, and defaults to zero.
units   The multiplicative factor the resolution of the depth buffer (essentially an offset value). Defaults to zero.

Definition at line 1928 of file sglStatelet.hpp.

sglPolygonOffset::~sglPolygonOffset ( ) [inline, virtual]
 

virtual destructor.

Definition at line 1933 of file sglStatelet.hpp.


Member Function Documentation

void sglPolygonOffset::setPolygonOffset ( float factor,
float units )
 

Set the polygon offset parameters. If both parameters are set to zero then polygon offset is disabled.

Parameters:
factor   The multiplicative factor for the maximum depth slope of the polygon. This can take on any floating point value.
units   The multiplicative factor the resolution of the depth buffer (essentially an offset value).

Referenced by sglPolygonOffset().

void sglPolygonOffset::getPolygonOffset ( float & factor,
float & units ) const [inline]
 

Query the polygon offset parameters.

Parameters:
factor   On return, contains the polygon offset factor.
units   On return, contains the polygon offset units value.

Definition at line 1948 of file sglStatelet.hpp.

bool sglPolygonOffset::getPolygonOffsetFlag ( ) const [inline]
 

Query whether or not polygon offset is enable (it compares the two parameters to zero as a convenience to the user).

Returns:
true if either parameter is non-zero; otherwise, false.

Definition at line 1958 of file sglStatelet.hpp.

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

Apply this state change to the current rendering state.

Parameters:
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 sglPolygonOffset::getSorted ( ) const [inline, virtual]
 

Query the sorting mode for this statelet.

Returns:
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 1964 of file sglStatelet.hpp.

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

Output the state of this node to the specified ostream.

Parameters:
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:09 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001