dtCore::ShaderParamTexture Class Reference

This class contains the logic and attributes necessary to contain a Texture shader parameter. More...

#include <shaderparamtexture.h>

Inheritance diagram for dtCore::ShaderParamTexture:

dtCore::ShaderParameter dtCore::Base dtCore::ShaderParamTexture2D

List of all members.

Public Member Functions

 ShaderParamTexture (const std::string &name)
 Constructs the shader parameter.
virtual const
ShaderParameter::ParamType
GetType () const =0
 Gets the type of this parameter.
virtual void AttachToRenderState (osg::StateSet &stateSet)=0
 Assigns the necessary texture states for this parameter to the render state.
virtual void Update ()=0
 Updates the texture states of the shader parameter.
virtual ShaderParameterClone ()=0
 Makes a deep copy of the Shader Parameter.
virtual void SetTexture (const std::string &path)
 Sets the path to the texture to use for this parameter.
const std::string & GetTexture () const
 Gets the current texture path string.
void SetAddressMode (const TextureAxis &axis, const AddressMode &mode)
 Sets the texture addressing mode.
const AddressModeGetAddressMode (const TextureAxis &axis)
 Gets the address mode assigned to the specified texture axis.
void SetTextureUnit (unsigned int unit)
 Sets the texture unit to use for this texture parameter.
unsigned int GetTextureUnit () const
 Gets the texture unit currently assigned to this shader parameter.
void SetTextureSourceType (const TextureSourceType &type)
 Sets the source texture type of this parameter.
const TextureSourceTypeGetTextureSourceType () const
 Gets the source texture type of this parameter.

Protected Member Functions

virtual ~ShaderParamTexture ()
 Cleans up the parameter.
void SetTextureObject (osg::Texture &tex)
 Sets the texture state attribute used by this shader parameter.
osg::Texture * GetTextureObject ()
 Gets the texture object currently assigned to this shader parameter.
bool IsImageSourceDirty () const
 Gets whether or not the image used by this texture has been changed.
void SetImageSourceDirty (bool flag)
 Sets whether or not the image used by this texture has changed since the last update.

Protected Attributes

bool mImageSrcChanged
unsigned int mTextureUnit
const AddressModemTextureAddressMode [4]
const TextureSourceTypemSourceType
dtCore::RefPtr< osg::Texture > mTextureObject
std::string mTexturePath

Classes

class  AddressMode
 Specifies the different texture addressing or texture wrap modes that can be assigned to this parameter. More...
class  TextureAxis
 An enumeration of the four texture axis. More...
class  TextureSourceType
 This enumeration defines the different types of sources that may be used for a texture parameter. More...


Detailed Description

This class contains the logic and attributes necessary to contain a Texture shader parameter.

A Texture parameter is a parameter that contains the information and state necessary to encapsulate a texture map and its associated properties.

Note:
For specialized classes see the Texture1D, Texture2D, and Texture3D subclasses.

Constructor & Destructor Documentation

dtCore::ShaderParamTexture::ShaderParamTexture ( const std::string &  name  ) 

Constructs the shader parameter.

Parameters:
name The name of the shader parameter.
Note:
If this is to be used by a GLSL shader, the name must match the name of the uniform variable.

dtCore::ShaderParamTexture::~ShaderParamTexture (  )  [protected, virtual]

Cleans up the parameter.


Member Function Documentation

virtual const ShaderParameter::ParamType& dtCore::ShaderParamTexture::GetType (  )  const [pure virtual]

Gets the type of this parameter.

Implements dtCore::ShaderParameter.

Implemented in dtCore::ShaderParamTexture2D.

virtual void dtCore::ShaderParamTexture::AttachToRenderState ( osg::StateSet &  stateSet  )  [pure virtual]

Assigns the necessary texture states for this parameter to the render state.

Implements dtCore::ShaderParameter.

Implemented in dtCore::ShaderParamTexture2D.

virtual void dtCore::ShaderParamTexture::Update (  )  [pure virtual]

Updates the texture states of the shader parameter.

This includes changes to the texture source or texture addressing parameters.

Implements dtCore::ShaderParameter.

Implemented in dtCore::ShaderParamTexture2D.

virtual ShaderParameter* dtCore::ShaderParamTexture::Clone (  )  [pure virtual]

Makes a deep copy of the Shader Parameter.

Used when a user assigns a shader to a node because we clone the template shader and its parameters. Note - Like Update(), this is a pure virtual method that must be implemented on each param.

Implements dtCore::ShaderParameter.

Implemented in dtCore::ShaderParamTexture2D.

virtual void dtCore::ShaderParamTexture::SetTexture ( const std::string &  path  )  [inline, virtual]

Sets the path to the texture to use for this parameter.

Parameters:
path The path to the texture file. Must be relative to the current delta3d data file path.

Reimplemented in dtCore::ShaderParamTexture2D.

const std::string& dtCore::ShaderParamTexture::GetTexture (  )  const [inline]

Gets the current texture path string.

Returns:
A string containing the path to this parameter's texture.

void dtCore::ShaderParamTexture::SetAddressMode ( const TextureAxis axis,
const AddressMode mode 
)

Sets the texture addressing mode.

This is applied when texture coordinates wishing to access this texture parameter fall outside of the range 0.0 - 1.0.

Parameters:
axis The axis enumeration to assign the address mode to.
mode The address mode enumeration to assign.

Reimplemented in dtCore::ShaderParamTexture2D.

const ShaderParamTexture::AddressMode & dtCore::ShaderParamTexture::GetAddressMode ( const TextureAxis axis  ) 

Gets the address mode assigned to the specified texture axis.

Parameters:
axis The texture axis to query.

void dtCore::ShaderParamTexture::SetTextureUnit ( unsigned int  unit  )  [inline]

Sets the texture unit to use for this texture parameter.

Parameters:
unit The texture unit.

unsigned int dtCore::ShaderParamTexture::GetTextureUnit (  )  const [inline]

Gets the texture unit currently assigned to this shader parameter.

Returns:
The texture unit.

void dtCore::ShaderParamTexture::SetTextureSourceType ( const TextureSourceType type  )  [inline]

Sets the source texture type of this parameter.

Parameters:
type The source type.
See also:
TextureSourceType
Note:
This does not dirty the parameter state. If this method is called after the parameter has been assigned to a render state, it must be reassigned after calling this method to ensure the texture gets uploaded to the graphics hardware.

const TextureSourceType& dtCore::ShaderParamTexture::GetTextureSourceType (  )  const [inline]

Gets the source texture type of this parameter.

Returns:
The source type currently in use by this parameter.

void dtCore::ShaderParamTexture::SetTextureObject ( osg::Texture &  tex  )  [inline, protected]

Sets the texture state attribute used by this shader parameter.

Parameters:
tex The texture state attribute to set.

osg::Texture* dtCore::ShaderParamTexture::GetTextureObject (  )  [inline, protected]

Gets the texture object currently assigned to this shader parameter.

Returns:
The current texture object.

bool dtCore::ShaderParamTexture::IsImageSourceDirty (  )  const [inline, protected]

Gets whether or not the image used by this texture has been changed.

Returns:
True if the source image has been changed, false otherwise.

void dtCore::ShaderParamTexture::SetImageSourceDirty ( bool  flag  )  [inline, protected]

Sets whether or not the image used by this texture has changed since the last update.

Parameters:
flag True if it has changed, false otherwise.


Member Data Documentation

bool dtCore::ShaderParamTexture::mImageSrcChanged [protected]

unsigned int dtCore::ShaderParamTexture::mTextureUnit [protected]

const AddressMode* dtCore::ShaderParamTexture::mTextureAddressMode[4] [protected]

const TextureSourceType* dtCore::ShaderParamTexture::mSourceType [protected]

dtCore::RefPtr<osg::Texture> dtCore::ShaderParamTexture::mTextureObject [protected]

std::string dtCore::ShaderParamTexture::mTexturePath [protected]


http://www.delta3d.org
2.0.0 generated 14 Feb 2008