dtCore::ShaderGroup Class Reference

This class is a container for shaders. More...

#include <shadergroup.h>

List of all members.

Public Member Functions

 ShaderGroup (const std::string &groupName)
 Constructs an empty shader group.
const std::string & GetName () const
 Gets the name currently assigned to this group.
void AddShader (ShaderProgram &shader, bool isDefault=false)
 Adds a shader to the group's list of shaders.
void RemoveShader (ShaderProgram &shader)
 Removes the specified shader from this shader group.
void RemoveShader (const std::string &shaderName)
 Removes the shader with the specified name from this shader group.
void RemoveAllShaders ()
 Clears the group's list of shaders.
ShaderProgramFindShader (const std::string &name)
 Searches the group for a shader with the specified name.
const ShaderProgramFindShader (const std::string &name) const
 Searches the group for a shader with the specified name.
unsigned int GetNumShaders () const
 Gets the number of shaders currently owned by this shader group.
void GetAllShaders (std::vector< dtCore::RefPtr< ShaderProgram > > &toFill)
 Gets a list of all the shaders owned by this shader group.
const ShaderProgramGetDefaultShader () const
 Gets the default shader assigned to this group.
ShaderProgramGetDefaultShader ()
 Non const verstion of GetDefaultShader().
virtual void Update ()
 Updates this shader group's state by calling update on each shader it is currently maintaining.
void SetDirty (bool flag)
 Sets the dirty flag of this shader group.
bool IsDirty () const
 Gets the dirty bit of this shader group.

Protected Member Functions

virtual ~ShaderGroup ()
 Destroys the shader group.


Detailed Description

This class is a container for shaders.

It allows shaders to be logically grouped together providing a simple way to assign shaders to actors. If a shader group contains more than a default shader (all defined in the Shader Definitions XML file) then it is the actor's responsibility to find the appropriate shader from the group and ask the shader manager to apply it.


Constructor & Destructor Documentation

dtCore::ShaderGroup::ShaderGroup ( const std::string &  groupName  ) 

Constructs an empty shader group.

Parameters:
groupName Name of this group. Group names must be unique.

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

Destroys the shader group.


Member Function Documentation

const std::string& dtCore::ShaderGroup::GetName (  )  const [inline]

Gets the name currently assigned to this group.

Returns:
The groups name.

void dtCore::ShaderGroup::AddShader ( ShaderProgram shader,
bool  isDefault = false 
)

Adds a shader to the group's list of shaders.

Parameters:
shader The new shader to add to the group. Note, if a shader with the same name already exists in the group, an exception is thrown.
isDefault If true, this shader is set as the default shader.
See also:
GetDefaultShader()

void dtCore::ShaderGroup::RemoveShader ( ShaderProgram shader  ) 

Removes the specified shader from this shader group.

Parameters:
shader The shader to remove.

void dtCore::ShaderGroup::RemoveShader ( const std::string &  shaderName  ) 

Removes the shader with the specified name from this shader group.

Parameters:
shaderName The name of the shader to remove. If a shader is not found with that name a warning is logged and this method becomes a no-op.

void dtCore::ShaderGroup::RemoveAllShaders (  )  [inline]

Clears the group's list of shaders.

ShaderProgram * dtCore::ShaderGroup::FindShader ( const std::string &  name  ) 

Searches the group for a shader with the specified name.

Returns:
The shader if found, or NULL if the shader could not be located.

const ShaderProgram * dtCore::ShaderGroup::FindShader ( const std::string &  name  )  const

Searches the group for a shader with the specified name.

(const-version).

Returns:
A const pointer to the shader or NULL if the shader could not be found.

unsigned int dtCore::ShaderGroup::GetNumShaders (  )  const [inline]

Gets the number of shaders currently owned by this shader group.

Returns:
The shader count.

void dtCore::ShaderGroup::GetAllShaders ( std::vector< dtCore::RefPtr< ShaderProgram > > &  toFill  ) 

Gets a list of all the shaders owned by this shader group.

Parameters:
toFill A list to be filled with the shaders in this group.
Note:
The specified vector parameter is cleared before filling.

const ShaderProgram* dtCore::ShaderGroup::GetDefaultShader (  )  const [inline]

Gets the default shader assigned to this group.

Returns:
The default shader.
Note:
The default shader is either the first shader in the group's list, or the shader specified as default when it was added, or NULL if there are no shaders in this group.

ShaderProgram* dtCore::ShaderGroup::GetDefaultShader (  )  [inline]

Non const verstion of GetDefaultShader().

void dtCore::ShaderGroup::Update (  )  [virtual]

Updates this shader group's state by calling update on each shader it is currently maintaining.

Note:
As with the Shader::Update method, this method does not rebind shader sources. Must call ShaderManager::AssignShaderFromTemplate for shader sources to get reloaded and rebound.

void dtCore::ShaderGroup::SetDirty ( bool  flag  )  [inline]

Sets the dirty flag of this shader group.

Parameters:
flag True if dirty, false otherwise.

bool dtCore::ShaderGroup::IsDirty (  )  const [inline]

Gets the dirty bit of this shader group.

Returns:
True if dirty, false otherwise.


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