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

sglMultiTextureStatelet Class Reference

#include <sglStatelet.hpp>

Inheritance diagram for sglMultiTextureStatelet::

sglStatelet sglObject List of all members.

Public Methods

 sglMultiTextureStatelet (sglTexturingStatelet *statelet, unsigned int unit=0)
virtual ~sglMultiTextureStatelet ()
void setTextureUnit (unsigned int unit)
unsigned int getTextureUnit () const
void setStatelet (sglTexturingStatelet *statelet)
sglTexturingStateletgetStatelet () const
void apply (sglCurrState *curr_state) const
virtual bool getSorted () const

Protected Methods

unsigned int getType () const

Detailed Description

This statelet manages the dispatch of the various sglTexturingStatelet subclasses (sglTexture, sglTexEnv, sglTexGen, and sglTextureMatrix) to the different texture units. Because this is handled differently from the other (non-texture related) statelets the default constructor is not necessary nor available.


The following example shows how to set up two texture units with different textures. Note how the sglTexCoords class is used to specify different texture coordinates for the different units:

   vector<sglStatelet*> state;
   vector<sglTexCoords> tex_coords;

   // setup for unit 0 (a 2D texture)
   sglTexture *tex0 = new sglTexture2D;
   sglTexEnv *tenv0 = new sglTexEnv;
   sglTextureMatrix *tmat0 = new sglTextureMatrix(...);

   sglVec2f *tcoords0 = new sglVec2f[...];
   tex_coords.push_back(sglTexCoords((float*)tcoords0, 2));

   state->push_back(new sglMultiTextureStatelet(tex0, 0));
   state->push_back(new sglMultiTextureStatelet(tenv0, 0));
   state->push_back(new sglMultiTextureStatelet(tmat0, 0));

   // setup for unit 1 (a 1D texture)
   sglTexture *tex1 = new sglTexture1D;

   float *tcoords1 = new float[...];
   tex_coords.push_back(sglTexCoords(tcoords1, 1));

   state->push_back(new sglMultiTextureStatelet(tex1, 1));
   state->push_back(new sglMultiTextureStatelet(tgen0, 1));

   // some subclass of sglDrawable...
   geometry->setState(0, state, tex_coords);

Definition at line 2243 of file sglStatelet.hpp.

Constructor & Destructor Documentation

sglMultiTextureStatelet::sglMultiTextureStatelet ( sglTexturingStatelet * statelet,
unsigned int unit = 0 ) [inline]


statelet   Pointer to the managed sglTexturingStatelet.
unit   Index of the texture unit to which to apply the statelet. This must be in the range [0 .. sgl::s_num_texture_units - 1] and defaults to zero.

Definition at line 2252 of file sglStatelet.hpp.

sglMultiTextureStatelet::~sglMultiTextureStatelet ( ) [virtual]

Virtual destructor. This will dereference the contained statelet and if its reference count goes to zero it will be destructed as well.

Member Function Documentation

void sglMultiTextureStatelet::setTextureUnit ( unsigned int unit ) [inline]

Set the texture unit to which the contained sglTexturingStatelet object is applied.

unit   Index of the texture unit. This should be in the range of [0 .. sgl::s_num_texture_units - 1]. (Values out if this range will result it being applied to unit 0?)

Definition at line 2270 of file sglStatelet.hpp.

unsigned int sglMultiTextureStatelet::getTextureUnit ( ) const [inline]

Query the current texture unit.

The current texture unit in the range [0 .. sgl::s_num_texture_units - 1].

Definition at line 2276 of file sglStatelet.hpp.

void sglMultiTextureStatelet::setStatelet ( sglTexturingStatelet * statelet )

Set the current sglTexturingStatelet object. This will reference the new one (increment the reference count) and dereference any previous statelet. If the previous statelet's reference count goes to zero it will NOT be deleted.

statelet   Pointer to the texturing statelet to be managed.

Referenced by sglMultiTextureStatelet().

sglTexturingStatelet * sglMultiTextureStatelet::getStatelet ( ) const [inline]

Query the current sglTexturingStateletObject.

Pointer to the current statelet.

Definition at line 2289 of file sglStatelet.hpp.

void sglMultiTextureStatelet::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 sglMultiTextureStatelet::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 2295 of file sglStatelet.hpp.

unsigned int sglMultiTextureStatelet::getType ( ) const [protected, virtual]

Get an identifier for the type of this statelet.

The StateEnum corresponding to the type of statelet. For texturing statelets beyond the first texture unit integers beyond the last StateEnum value are returned.

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