VTK
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
vtkShader Class Reference

#include <vtkShader.h>

Inheritance diagram for vtkShader:
Inheritance graph
[legend]
Collaboration diagram for vtkShader:
Collaboration graph
[legend]

List of all members.

Public Types

typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkShaderNewInstance () const
virtual void PrintSelf (ostream &os, vtkIndent indent)
virtual int Compile ()=0
virtual void PassShaderVariables (vtkActor *actor, vtkRenderer *ren)
virtual void Bind ()
virtual void Unbind ()
virtual void ReleaseGraphicsResources (vtkWindow *)
int HasShaderVariable (const char *name)
int GetShaderVariableSize (const char *name)
int GetShaderVariableType (const char *name)
void SetXMLShader (vtkXMLShader *)
virtual vtkXMLShaderGetXMLShader ()
void AddShaderVariable (const char *name, int num_of_elements, const int *values)
void AddShaderVariable (const char *name, int num_of_elements, const float *values)
void AddShaderVariable (const char *name, int num_of_elements, const double *values)
int GetShaderVariable (const char *name, int *values)
int GetShaderVariable (const char *name, float *values)
int GetShaderVariable (const char *name, double *values)

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkShaderSafeDownCast (vtkObjectBase *o)

Protected Types

enum  MatrixOrders { RowMajor, ColumnMajor }

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
void SetUniformParameter (vtkActor *, vtkRenderer *, vtkXMLDataElement *)
void SetCameraParameter (vtkActor *, vtkRenderer *, vtkXMLDataElement *)
void SetPropertyParameter (vtkActor *, vtkRenderer *, vtkXMLDataElement *)
void SetLightParameter (vtkActor *, vtkRenderer *, vtkXMLDataElement *)
void SetMatrixParameter (vtkActor *, vtkRenderer *, vtkXMLDataElement *)
void SetSamplerParameter (vtkActor *, vtkRenderer *, vtkXMLDataElement *)
void SetApplicationParameter (vtkXMLDataElement *)
virtual void SetShaderParameters (vtkActor *, vtkRenderer *, vtkXMLDataElement *)
virtual void SetUniformParameter (const char *name, int numValues, const int *value)=0
virtual void SetUniformParameter (const char *name, int numValues, const float *value)=0
virtual void SetUniformParameter (const char *name, int numValues, const double *value)=0
virtual void SetMatrixParameter (const char *name, int numValues, int order, const float *value)=0
virtual void SetMatrixParameter (const char *name, int numValues, int order, const double *value)=0
virtual void SetMatrixParameter (const char *name, const char *state_matix_type, const char *transform_type)=0
virtual void SetSamplerParameter (const char *name, vtkTexture *texture, int textureIndex)=0

Protected Attributes

vtkXMLShaderXMLShader
vtkShaderInternals * Internals
vtkTimeStamp PassShaderVariablesTime
int GetScope ()
 vtkShader ()
 ~vtkShader ()

Detailed Description

vtkShader is a base class for interfacing VTK to hardware shader libraries. vtkShader interprets a vtkXMLDataElement that describes a particular shader. Descendants of this class inherit this functionality and additionally interface to specific shader libraries like NVidia's Cg and OpenGL2.0 (GLSL) to perform operations, on individual shaders.

During each render, the vtkShaderProgram calls Compile(), PassShaderVariables(), Bind() and after the actor has been rendered, calls Unbind(), in that order.

See also:
vtkCgShader vtkGLSLShader
Thanks:
Shader support in VTK includes key contributions by Gary Templet at Sandia National Labs.

Definition at line 59 of file vtkShader.h.


Member Typedef Documentation

Reimplemented from vtkObject.

Reimplemented in vtkGLSLShader.

Definition at line 62 of file vtkShader.h.


Member Enumeration Documentation

enum vtkShader::MatrixOrders [protected]
Enumerator:
RowMajor 
ColumnMajor 

Definition at line 142 of file vtkShader.h.


Constructor & Destructor Documentation

vtkShader::vtkShader ( ) [protected]

Returns the scope of the shader i.e. if it's a vertex or fragment shader. (vtkXMLShader::SCOPE_VERTEX or vtkXMLShader::SCOPE_FRAGMENT).

vtkShader::~vtkShader ( ) [protected]

Returns the scope of the shader i.e. if it's a vertex or fragment shader. (vtkXMLShader::SCOPE_VERTEX or vtkXMLShader::SCOPE_FRAGMENT).


Member Function Documentation

static int vtkShader::IsTypeOf ( const char *  name) [static]

Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

Reimplemented in vtkGLSLShader.

virtual int vtkShader::IsA ( const char *  name) [virtual]

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

Reimplemented in vtkGLSLShader.

static vtkShader* vtkShader::SafeDownCast ( vtkObjectBase o) [static]

Reimplemented from vtkObject.

Reimplemented in vtkGLSLShader.

virtual vtkObjectBase* vtkShader::NewInstanceInternal ( ) const [protected, virtual]

Reimplemented from vtkObject.

Reimplemented in vtkGLSLShader.

Reimplemented from vtkObject.

Reimplemented in vtkGLSLShader.

virtual void vtkShader::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

Reimplemented in vtkGLSLShader.

virtual int vtkShader::Compile ( ) [pure virtual]

Called to compile the shader code. The subclasses must only compile the code in this method. Returns if the compile was successful. Subclasses should compile the code only if it was not already compiled.

Implemented in vtkGLSLShader.

virtual void vtkShader::PassShaderVariables ( vtkActor actor,
vtkRenderer ren 
) [virtual]

Called to pass VTK actor/property/light values and other Shader variables over to the shader. This is called by the ShaderProgram during each render.

virtual void vtkShader::Bind ( ) [inline, virtual]

In this method the shader can enable/bind itself. This is applicable only to Cg, since in GLSL, individual shaders in a program can't be enabled/bound.

Definition at line 79 of file vtkShader.h.

virtual void vtkShader::Unbind ( ) [inline, virtual]

Called to unbind the shader. As with Bind(), this is only applicable to Cg.

Definition at line 83 of file vtkShader.h.

virtual void vtkShader::ReleaseGraphicsResources ( vtkWindow ) [inline, virtual]

Release any graphics resources that are being consumed by this actor. The parameter window could be used to determine which graphic resources to release.

Reimplemented in vtkGLSLShader.

Definition at line 88 of file vtkShader.h.

Get/Set the XMLShader representation for this shader. A shader is not valid without a XMLShader.

virtual vtkXMLShader* vtkShader::GetXMLShader ( ) [virtual]

Get/Set the XMLShader representation for this shader. A shader is not valid without a XMLShader.

int vtkShader::HasShaderVariable ( const char *  name)

Indicates if a variable by the given name exists.

void vtkShader::AddShaderVariable ( const char *  name,
int  num_of_elements,
const int values 
)

Methods to add shader variables to this shader. The shader variable type must match with that declared in the Material xml, otherwise, the variable is not made available to the shader.

void vtkShader::AddShaderVariable ( const char *  name,
int  num_of_elements,
const float values 
)

Methods to add shader variables to this shader. The shader variable type must match with that declared in the Material xml, otherwise, the variable is not made available to the shader.

void vtkShader::AddShaderVariable ( const char *  name,
int  num_of_elements,
const double values 
)

Methods to add shader variables to this shader. The shader variable type must match with that declared in the Material xml, otherwise, the variable is not made available to the shader.

int vtkShader::GetShaderVariableSize ( const char *  name)

Get number of elements in a Shader variable. Return 0 if failed to find the shader variable.

int vtkShader::GetShaderVariableType ( const char *  name)

Returns the type of a Shader variable with the given name. Return 0 on error.

int vtkShader::GetShaderVariable ( const char *  name,
int values 
)

Methods to get the value of shader variables with the given name. Values must be at least the size of the shader variable (obtained by GetShaderVariableSize(). Returns if the operation was successful.

int vtkShader::GetShaderVariable ( const char *  name,
float values 
)

Methods to get the value of shader variables with the given name. Values must be at least the size of the shader variable (obtained by GetShaderVariableSize(). Returns if the operation was successful.

int vtkShader::GetShaderVariable ( const char *  name,
double values 
)

Methods to get the value of shader variables with the given name. Values must be at least the size of the shader variable (obtained by GetShaderVariableSize(). Returns if the operation was successful.

Returns the scope of the shader i.e. if it's a vertex or fragment shader. (vtkXMLShader::SCOPE_VERTEX or vtkXMLShader::SCOPE_FRAGMENT).

virtual void vtkShader::SetShaderParameters ( vtkActor ,
vtkRenderer ,
vtkXMLDataElement  
) [protected, virtual]

Runs through the XML element children to locate uniform variable elements and process them.

void vtkShader::SetUniformParameter ( vtkActor ,
vtkRenderer ,
vtkXMLDataElement  
) [protected]

Processes <Uniform> elements.

void vtkShader::SetCameraParameter ( vtkActor ,
vtkRenderer ,
vtkXMLDataElement  
) [protected]

Processes <CameraUniform>

void vtkShader::SetPropertyParameter ( vtkActor ,
vtkRenderer ,
vtkXMLDataElement  
) [protected]

Processes <PropertyUniform>

void vtkShader::SetLightParameter ( vtkActor ,
vtkRenderer ,
vtkXMLDataElement  
) [protected]

Processes <LightUniform>

void vtkShader::SetMatrixParameter ( vtkActor ,
vtkRenderer ,
vtkXMLDataElement  
) [protected]

Process <MatrixUniform>

void vtkShader::SetSamplerParameter ( vtkActor ,
vtkRenderer ,
vtkXMLDataElement  
) [protected]

Process <SamplerUniform>

Process <ApplicationUniform>

virtual void vtkShader::SetUniformParameter ( const char *  name,
int  numValues,
const int value 
) [protected, pure virtual]

Equivalent to cgGLSetParameter and glUniform. Subclasses must override these and perform GLSL or Cg calls.

Implemented in vtkGLSLShader.

virtual void vtkShader::SetUniformParameter ( const char *  name,
int  numValues,
const float value 
) [protected, pure virtual]

Equivalent to cgGLSetParameter and glUniform. Subclasses must override these and perform GLSL or Cg calls.

Implemented in vtkGLSLShader.

virtual void vtkShader::SetUniformParameter ( const char *  name,
int  numValues,
const double value 
) [protected, pure virtual]

Equivalent to cgGLSetParameter and glUniform. Subclasses must override these and perform GLSL or Cg calls.

Implemented in vtkGLSLShader.

virtual void vtkShader::SetMatrixParameter ( const char *  name,
int  numValues,
int  order,
const float value 
) [protected, pure virtual]

Equivalent to cgGLSetMatrixParameterfc and glUniformMatrix. Subclasses must override these and perform GLSL or Cg calls.

Implemented in vtkGLSLShader.

virtual void vtkShader::SetMatrixParameter ( const char *  name,
int  numValues,
int  order,
const double value 
) [protected, pure virtual]

Equivalent to cgGLSetMatrixParameterfc and glUniformMatrix. Subclasses must override these and perform GLSL or Cg calls.

Implemented in vtkGLSLShader.

virtual void vtkShader::SetMatrixParameter ( const char *  name,
const char *  state_matix_type,
const char *  transform_type 
) [protected, pure virtual]

Equivalent to cgGLSetMatrixParameterfc and glUniformMatrix. Subclasses must override these and perform GLSL or Cg calls.

Implemented in vtkGLSLShader.

virtual void vtkShader::SetSamplerParameter ( const char *  name,
vtkTexture texture,
int  textureIndex 
) [protected, pure virtual]

Establishes the given texture as the uniform sampler to perform lookups on. The textureIndex argument corresponds to the indices of the textures in a vtkProperty. Subclass may have to cast the texture to vtkOpenGLTexture to obtain the GLuint for texture this texture. Subclasses must override these and perform GLSL or Cg calls.

Implemented in vtkGLSLShader.


Member Data Documentation

Definition at line 138 of file vtkShader.h.

vtkShaderInternals* vtkShader::Internals [protected]

Definition at line 139 of file vtkShader.h.

Definition at line 211 of file vtkShader.h.


The documentation for this class was generated from the following file: