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

sglBlending Class Reference

#include <sglStatelet.hpp>

Inheritance diagram for sglBlending::

sglStatelet sglObject List of all members.

Public Types

enum  BlendFuncEnum {
  eZERO = GL_ZERO,
  eONE = GL_ONE,
  eSRC_COLOR = GL_SRC_COLOR,
  eONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
  eDST_COLOR = GL_DST_COLOR,
  eONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
  eSRC_ALPHA = GL_SRC_ALPHA,
  eONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
  eDST_ALPHA = GL_DST_ALPHA,
  eONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
  eSRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE
}

Public Methods

 sglBlending (BlendFuncEnum src_func=eSRC_ALPHA, BlendFuncEnum dst_func=eONE_MINUS_SRC_ALPHA, bool on=false)
virtual ~sglBlending ()
void enable (bool on)
bool isEnabled () const
void setBlendFunc (BlendFuncEnum src_func, BlendFuncEnum dst_func)
void getBlendFunc (BlendFuncEnum &src_func, BlendFuncEnum &dst_func) 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 controls the OpenGL blending state by issuing the glBlendFunc() function and the glEnable(GL_BLEND_FUNC). Even when this statelet is disabled by calling sglBlending::enable(false), the blend function defined here is used by the sglTransparency and most of the sglAntiAlias* statelets to perform their blending. Because of this the default blending function is SRC_ALPHA, ONE_MINUS_SRC_ALPHA. If this blending mode is not desired for some of these other statelets then an sglBlending statelet can be included which defines the desired blend function (without ever enabling it).

Example:

   sglBlending *blending = new sglBlending;  // defaults to disabled
   blending->setBlendFunc(sglBlending::eSRC_ALPHA,
                          sglBlending::eONE_MINUS_SRC_ALPHA);
   blending->enable(true);

Todo:
Add support for GL_EXT_blend_color.

Definition at line 591 of file sglStatelet.hpp.


Member Enumeration Documentation

enum sglBlending::BlendFuncEnum
 

The list of possible blend functions.

Definition at line 595 of file sglStatelet.hpp.


Constructor & Destructor Documentation

sglBlending::sglBlending ( BlendFuncEnum src_func = eSRC_ALPHA,
BlendFuncEnum dst_func = eONE_MINUS_SRC_ALPHA,
bool on = false ) [inline]
 

Constructor (also default constructor).

Parameters:
src_func   Enum indicating how the source values are combined in the blend function (default is sglBlending::eSRC_ALPHA).
dst_func   Enum indicating how the destination values are combined in the blend function (default is sglBlending::eONE_MINUS_SRC_ALPHA).
on   True to enable blending otherwise false (default is false).

Definition at line 618 of file sglStatelet.hpp.

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

virtual destructor.

Definition at line 626 of file sglStatelet.hpp.


Member Function Documentation

void sglBlending::enable ( bool on ) [inline]
 

Enable or disable blending.

Parameters:
on   True to enable and false to disable.

Definition at line 631 of file sglStatelet.hpp.

bool sglBlending::isEnabled ( ) const [inline]
 

Query whether or not blending is enabled.

Returns:
True if enabled and false if disabled.

Definition at line 636 of file sglStatelet.hpp.

void sglBlending::setBlendFunc ( BlendFuncEnum src_func,
BlendFuncEnum dst_func ) [inline]
 

Set the blend function factors for source and destination values.

Parameters:
src_func   The factor used on the source values (one of the BlendFuncEnum tokens).
dst_func   The factor used on the destination values.

Definition at line 643 of file sglStatelet.hpp.

void sglBlending::getBlendFunc ( BlendFuncEnum & src_func,
BlendFuncEnum & dst_func ) const [inline]
 

Query the current blend function factors.

Parameters:
src_func   On return will contain the factor enum for source.
dst_func   On return will contain the factor enum for destination.

Definition at line 650 of file sglStatelet.hpp.

void sglBlending::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 sglBlending::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 657 of file sglStatelet.hpp.

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