Base object for representing shader data.
#include <AlShader.h>
class AlShader : public AlObject , public AlAnimatable
AlShader();
virtual ~AlShader();
virtual statusCode deleteObject();
virtual AlObject *copyWrapper() const;
statusCode create();
virtual AlObjectType type() const;
virtual const char* name() const;
virtual statusCode setName( const char * );
statusCode parameter( const AlShadingFields, double& ) const;
statusCode setParameter( const AlShadingFields, const double );
statusCode blindData( int, long& , const char*& );
statusCode setBlindData( int, long, const char* );
statusCode removeBlindData( int user_type );
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();
AlShader* convertSolidToFileTexture( AlDagNode *, int ,boolean , const char * );
AlShader* convertEnvironmentToFileTexture( int , const char *, AlPixFile::Format, boolean );
This class encapsulates the basic functionality for checking and setting the name of a shader as well as accessing the textures that a particular shader refers to, and the animation on the shader. Shader objects are accessible through both the AlUniverse class and the objects that reference them (AlSurface and AlFace classes).
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().
The shader parameters can be accessed through the parameter() and setParameter() methods. Each shader has a specific set of parameters that are valid for it that depend on its type. The full list of shader parameters can be seen in the file AlShadingFields.h. For example, all parameters specific to the Blinn shader have names of the form kFLD_SHADING_BLINN_*. Parameters common to all shaders have the form kFLD_SHADING_COMMON_*. All parameters are treated as doubles even though this may not necessarily be what they are. This is done to make the interface as simple and consistent as possible.
statusCode AlShader::setName( const char *newName)
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
statusCode AlShader::setParameter( const AlShadingFields field,const double value )
AlTexture* AlShader::nextTexture( const AlTexture* last_texture ) const
statusCode AlShader::nextTextureD( AlTexture* last_texture ) const
statusCode AlShader::removeTexture( const char* fieldName )
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.
statusCode AlShader::addTexture( const char* fieldName, const char* textureName, AlTexture** returnCreatedTexture )
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.
Note: most of these names are also found on the widgets themselves (for example, ’sRock’ or ’Fractal’)
For example, to add shaders to the ’color’ fields, one would use commands such as
shader->addTexture( "color", "sRock" ) shader->addTexture( "color", "Fractal" )
statusCode AlShader::applyIteratorToTextures( AlIterator *iter, int &rc )
Applies 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.
statusCode AlShader::blindData( int user_type, long& size, const char *& data )
Obtains the size and address of a block of data associated with the object. If there is no data, then the size will be zero and the address of the data is NULL.
User_types between 0 and 13099 are reserved. If you would like to reserve a block of "user_types" please contact us.
statusCode AlShader::setBlindData( int user_type, long size, const char * data )
Associates a block of data with the object. If a block of data is already associated with this object and this user_type, the old block is replaced by a reference to the new block. The old block of data is not deleted.
AlShader* AlShader::convertSolidToFileTexture( AlDagNode *dagNode, int resolution, boolean antiAlias, const char * pixFilename )
If the current shader has a solid texture, this method copies this shader and converts the solid texture to a file texture for the specified dag node object. A pix file is created for the file texture using the resolution and anti-aliasing parameters specified. On failure, this method returns NULL.
Notes:
1. Valid resolutions are 8 .. 1024
2. This method will fail if either dagNode or pixFilename are NULL
3. dagNode should be a valid API pointer
AlShader* AlShader::convertEnvironmentToFileTexture(int resolution, const char * pixFilename, AlPixFile::Format pixFmt, boolean imageMap )