#include <AlShader.h>
class AlShader : public AlObject , public AlAnimatable
AlShader();
virtual ~AlShader();
virtual statusCode deleteObject();
virtual AlObject *copyWrapper() const;
statusCode create();
virtual AlAnimatable* asAnimatablePtr();
virtual AlObjectType type() const;
virtual AlShader* asShaderPtr();
virtual const char* name() const;
virtual statusCode setName( const char * );
statusCode parameter( const AlShadingFields, double* ) const;
statusCode parameter( const AlShadingFields, double& ) const;
statusCode setParameter( const AlShadingFields, const double );
const char* shadingModel() const;
statusCode setShadingModel( const char* );
AlTexture* firstTexture() const;
AlTexture* nextTexture( const AlTexture* ) const;
statusCode nextTextureD( AlTexture* ) const;
AlList* fields() const;
AlList* mappedFields() const;
statusCode addTexture( const char*, const char*, AlTexture**
returnedTexture = NULL );
statusCode removeTexture( const char* );
statusCode applyIteratorToTextures( AlIterator*, int& );
AlShader* copyObject();
boolean isUsed();
A shader object may reference textures. The firstTexture() and nextTexture() methods are used to access these textures.
firstTexture() returns the first texture that the shader object references. nextTexture() moves from a given referenced texture to the next texture in order, as related to the shader object. (See the similar methods for the AlTexture/AlEnvironment classes.)
The animation on a shader can be accessed through the firstChannel() and nextChannel() methods. All the channels on the shader can be deleted by calling deleteAnimation().
Summary
AlAnimatable *AlShader::asAnimatablePtr()
Description
This virtual function returns a non-null pointer to itself, indicating that it is safe to cast to an object of this class. AlShader::AlShader()
Description
Constructs an AlShader wrapper object. Use the create() method to initialize an AlShader. AlShader::~AlShader()
Description
Deletes an AlShader wrapper object. statusCode AlShader::create()
Description
Does any initialization and allocation of data for an AlShader. Allocates space for this AlShader and adds it to the global list of shaders in AlUniverse. The shader is initialized as the Alias default shader. Return codes
sSuccess - if creation succeeded. statusCode AlShader::deleteObject()
Description
Deletes the AlShader and the AlTextures hanging off of the shader. All objects that were assigned this shader will be assigned the default shader. Note that after this operation, any pointers to AlTextures that had been part of this shader will no longer be valid. Return codes
sSuccess - shader was deleted AlObject *AlShader::copyWrapper() const
Description
Return an exact duplicate of this AlShader wrapper. AlObjectType AlShader::type() const
Description
Returns the class identifier 'kShaderType'. AlShader* AlShader::asShaderPtr()
Description
This virtual function returns a non-null pointer to itself, indicating that it is safe to cast to an object of this class. const char* AlShader::name() const
Description
Returns the name of the shader. statusCode AlShader::setName( const char *newName)
Description
Changes the name of the shader to a new name. If the given name is not a unique one or contains illegal characters, then a new unique name is generated based on the given name and assigned to the shader. In this case, a status code of sNameChangedToUniqueOne is returned. It is illegal for the new name to be NULL. #, digits, upper case letters, lower case letters, and _ are valid characters Arguments
< newName - new name of the object Return codes
sSuccess - name was changed statusCode AlShader::parameter( const AlShadingFields field,double& result )const
Description
This method finds the value of a given shader field. Arguments
< field - shader field type Return codes
sSuccess - field was returned statusCode AlShader::setParameter( const AlShadingFields field,const double value )
Description
This method changes the value of the shader field. If the given field is not valid then a status code of sInvalidArgument is returned. Arguments
< field - shader field type Return codes
sSuccess - field was changed const char* AlShader::shadingModel() const
Description
This method returns a string representing the shading model. The returned string will be one of BLINN, PHONG, LAMBERT, or LIGHTSOURCE. statusCode AlShader::setShadingModel( const char* model )
Description
This method tries to set the shading model of the shader. The model must be one of LIGHTSOURCE, LAMBERT, BLINN, or PHONG. Return codes
sSuccess - the shading model was successfully set. AlTexture* AlShader::firstTexture() const
Description
Returns the first texture that this shader object references. If there are none then NULL is returned. AlTexture* AlShader::nextTexture( const AlTexture* last_texture ) const
Description
Returns the texture after the given one in the shader's texture list. Specifying NULL as parameter will return the first texture. Arguments
< last_texture - Texture from which to walk forward statusCode AlShader::nextTextureD( AlTexture* last_texture ) const
Description
Destructively points the last_texture wrapper to the next the texture after the given one in the shader's texture list. Arguments
<> last_texture - Texture from which to walk forward Return codes
sSuccess - the wrapper points to the next texture AlList* AlShader::fields() const
Description
This method returns an AlList of AlShadingFieldItems, each of which contains an AlShadingFields value valid for this shader. AlList* AlShader::mappedFields() const
Description
This method returns an AlList of AlMappedFieldItems, each of which contains a character string identifier identifying a field on this shader which may be texture mapped. Note that these strings are identical to the SDL identifiers and the complete list can be found in the SDL manual. statusCode AlShader::removeTexture( const char* fieldName )
Description
This method removes a texture from a particular field of the AlShader. The first argument is the name of the field which will have the texture applied to it. Only those fields valid for this shader should be provided; any others will cause this method to fail. Valid fields are any returned by the fields() method. Arguments
< fieldName - name of the field which will have the texture removed from it Return codes
sSuccess - the texture was added successfully. statusCode AlShader::addTexture( const char* fieldName, const char* textureName, AlTexture** returnCreatedTexture )
Description
This method adds a texture to a particular field of the AlShader. The first argument is the name of the field which will have the texture applied to it. Only those fields valid for this shader should be provided; any others will cause this method to fail. Valid fields are any returned by the fields() method. The second argument is the name of the texture type to apply to the field. The complete list of names is available in the SDL manual. shader->addTexture( "color", "sRock" ) shader->addTexture( "color", "Fractal" )
Arguments
< fieldName - name of the field which will have the texture applied to it Return codes
sSuccess - the texture was added successfully. statusCode AlShader::applyIteratorToTextures( AlIterator *iter, int &rc )
Description
Apply the given AlIterator to all textures in the shader. The second argument will be set to the return value of the last application of the iterator's function. See the AlIterator class for more information.
Arguments
< iter - the iterator to apply Return codes
sSuccess - the application of the iterator terminated normally AlShader *AlShader::copyObject()
Description
Copy this AlShader returning a pointer to the new copy or NULL if the copy failed. boolean AlShader::isUsed()
Description
Returns TRUE if the shader is being used by another object. Return value is FALSE otherwise.