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

sglTexEnv Class Reference

#include <sglTexEnv.hpp>

Inheritance diagram for sglTexEnv::

sglTexturingStatelet sglStatelet sglObject List of all members.

Public Types

enum  ModeEnum {
  eADD = GL_ADD,

Public Methods

 sglTexEnv ()
virtual ~sglTexEnv ()
void setMode (ModeEnum mode)
ModeEnum getMode () const
void setBlendColor (float r, float g, float b, float a)
void getBlendColor (float &r, float &g, float &b, float &a) const
void setCombinerParams (sglTexCombinerParams *params)
sglTexCombinerParamsgetCombinerParams () const
void setLODBias (float bias)
float getLODBias () const
void applyToUnit (sglCurrState *curr_state, unsigned int unit) const
virtual bool getSorted () const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Detailed Description

This statelet encapsulates OpenGL's glTexEnv*() functions which sets the texturing function for any subsequent textured geometry that is rendered. These functions affect how the texture interacts with the underlying colors in the polygons to which it is being applied. This statelet also encapsulates an ever expanding set of extensions (if available) that add new texturing functions:

   sglTexEnv *tenv = new sglTexEnv;
   tenv->setBlendColor(1.0f, 0.7f, 0.0f, 1.0f);

   if (sgl::s_texture_lod_bias_capable)
      tenv->setLODBias(sgl::s_max_texture_lod_bias);  // maximum

Definition at line 64 of file sglTexEnv.hpp.

Member Enumeration Documentation

enum sglTexEnv::ModeEnum

Tokens for the various texture environment modes.

Enumeration values:
eDECAL   Uses texture color. Only works with RGB and RGBA textures.
eREPLACE   Uses texture color, uses face alpha if texture format doesn't include alpha. Works with all internal texture formats.
eMODULATE   Modulates texture color with face color.
eADD   Adds the face color to the texture color (if extension is available). See sgl::s_texture_env_add_capable.
eBLEND   Blends the face with a blend color, and uses the face's color value somewhat like an alpha value to perform the blending.
eCOMBINE   The texel color is computed from a combination of multiple inputs (if extension is available). See sgl::s_texture_env_combine_capable.

Definition at line 68 of file sglTexEnv.hpp.

Constructor & Destructor Documentation

sglTexEnv::sglTexEnv ( )

Default constructor. The mode defaults to eMODULATE (the OpenGL default).

sglTexEnv::~sglTexEnv ( ) [virtual]

Virtual destructor.

Member Function Documentation

void sglTexEnv::setMode ( ModeEnum mode )

Set the texture function.

mode   One of the ModeEnum tokens. If eADD or eCombine is specified but is not supported through the extensions, then eMODULATE will be used instead. The default value is eMODULATE.

ModeEnum sglTexEnv::getMode ( ) const [inline]

Query the current texture function.

The ModeEnum token corresponding to the current texture function.

Definition at line 119 of file sglTexEnv.hpp.

void sglTexEnv::setBlendColor ( float r,
float g,
float b,
float a )

Set the blend color to be used if the texture function is eBLEND, or eCOMBINE with an eCONSTANT source parameter.

r   The red component of the blend color.
g   The green component of the blend color.
b   The blue component of the blend color.
a   The alpha component of the blend color.

void sglTexEnv::getBlendColor ( float & r,
float & g,
float & b,
float & a ) const

Query the current blend color.

r   On return, contains the red component of the blend color.
g   On return, contains the green component of the blend color.
b   On return, contains the blue component of the blend color.
a   On return, contains the alpha component of the blend color.

void sglTexEnv::setCombinerParams ( sglTexCombinerParams * params )

Set the parameters to use for the eCOMBINE mode. If params is set to NULL and eCOMBINE has been selected, eMODULATE will be used instead.

params   The combiner parameters.

sglTexCombinerParams * sglTexEnv::getCombinerParams ( ) const [inline]

Get the parameters used for the eCOMBINE mode. @erturn The combiner parameters.

Definition at line 148 of file sglTexEnv.hpp.

void sglTexEnv::setLODBias ( float bias )

Set the texture LOD bias which can affect which mipmap levels are chosen This is only available if the GL_EXT_texture_lod_bias extension is available; otherwise this factor is ignored.

bias   The bias value in the range [-sgl::s_max_texture_lod_bias .. sgl::s_max_texture_lod_bias]. Values outside this range will be clamped.

float sglTexEnv::getLODBias ( ) const [inline]

Query the current LOD bias factor.

The current LOD bias factor.

Definition at line 163 of file sglTexEnv.hpp.

void sglTexEnv::applyToUnit ( sglCurrState * curr_state,
unsigned int unit ) const [virtual]

Apply this state change to the current rendering state for the given texture unit.

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.
unit   Index for the texture unit (0 is the first).

Reimplemented from sglTexturingStatelet.

bool sglTexEnv::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 169 of file sglTexEnv.hpp.

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