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:
[legend]
Collaboration diagram for vtkShader:
[legend]

List of all members.

Public Types

typedef vtkObject Superclass
- Public Types inherited from vtkObject

Public Member Functions

virtual const char * GetClassName ()
virtual int IsA (const char *type)
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)
- Public Member Functions inherited from vtkObject
virtual void DebugOn ()
virtual void DebugOff ()
unsigned char GetDebug ()
void SetDebug (unsigned char debugFlag)
virtual void Modified ()
virtual unsigned long GetMTime ()
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
vtkCommandGetCommand (unsigned long tag)
void RemoveObserver (vtkCommand *)
void RemoveObservers (unsigned long event, vtkCommand *)
void RemoveObservers (const char *event, vtkCommand *)
int HasObserver (unsigned long event, vtkCommand *)
int HasObserver (const char *event, vtkCommand *)
void RemoveObserver (unsigned long tag)
void RemoveObservers (unsigned long event)
void RemoveObservers (const char *event)
void RemoveAllObservers ()
int HasObserver (unsigned long event)
int HasObserver (const char *event)
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
int InvokeEvent (unsigned long event, void *callData)
int InvokeEvent (const char *event, void *callData)
int InvokeEvent (unsigned long event)
int InvokeEvent (const char *event)
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
virtual void Delete ()
virtual void FastDelete ()
void Print (ostream &os)
virtual void Register (vtkObjectBase *o)
virtual void UnRegister (vtkObjectBase *o)
void SetReferenceCount (int)
void PrintRevisions (ostream &os)
virtual void PrintHeader (ostream &os, vtkIndent indent)
virtual void PrintTrailer (ostream &os, vtkIndent indent)
int GetReferenceCount ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkShaderSafeDownCast (vtkObject *o)
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
static void BreakOnError ()
static void SetGlobalWarningDisplay (int val)
static void GlobalWarningDisplayOn ()
static void GlobalWarningDisplayOff ()
static int GetGlobalWarningDisplay ()

Protected Types

enum  MatrixOrders { RowMajor, ColumnMajor }

Protected Member Functions

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 Member Functions inherited from vtkObject
 vtkObject ()
virtual ~vtkObject ()
virtual void RegisterInternal (vtkObjectBase *, int check)
virtual void UnRegisterInternal (vtkObjectBase *, int check)
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
void InternalReleaseFocus ()
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
virtual ~vtkObjectBase ()
virtual void CollectRevisions (ostream &os)
virtual void ReportReferences (vtkGarbageCollector *)
 vtkObjectBase (const vtkObjectBase &)
void operator= (const vtkObjectBase &)

Protected Attributes

vtkXMLShaderXMLShader
vtkShaderInternals * Internals
vtkTimeStamp PassShaderVariablesTime
- Protected Attributes inherited from vtkObject
unsigned char Debug
vtkTimeStamp MTime
vtkSubjectHelper * SubjectHelper
- Protected Attributes inherited from vtkObjectBase
int ReferenceCount
vtkWeakPointerBase ** WeakPointers
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 58 of file vtkShader.h.


Member Typedef Documentation

Reimplemented from vtkObject.

Reimplemented in vtkCgShader, and vtkGLSLShader.

Definition at line 61 of file vtkShader.h.


Member Enumeration Documentation

enum vtkShader::MatrixOrders
protected
Enumerator:
RowMajor 
ColumnMajor 

Definition at line 141 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

virtual const char* vtkShader::GetClassName ( )
virtual

Reimplemented from vtkObject.

Reimplemented in vtkCgShader, and vtkGLSLShader.

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 vtkCgShader, and 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 vtkCgShader, and vtkGLSLShader.

static vtkShader* vtkShader::SafeDownCast ( vtkObject o)
static

Reimplemented from vtkObject.

Reimplemented in vtkCgShader, and 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 vtkCgShader, and 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 vtkCgShader, and 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.

Reimplemented in vtkCgShader.

virtual void vtkShader::Bind ( )
inlinevirtual

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.

Reimplemented in vtkCgShader.

Definition at line 78 of file vtkShader.h.

virtual void vtkShader::Unbind ( )
inlinevirtual

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

Reimplemented in vtkCgShader.

Definition at line 82 of file vtkShader.h.

virtual void vtkShader::ReleaseGraphicsResources ( vtkWindow )
inlinevirtual

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 vtkCgShader, and vtkGLSLShader.

Definition at line 87 of file vtkShader.h.

void vtkShader::SetXMLShader ( vtkXMLShader )

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.

int vtkShader::GetScope ( )

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  
)
protectedvirtual

Runs throught 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>

void vtkShader::SetApplicationParameter ( vtkXMLDataElement )
protected

Process <ApplicationUniform>

virtual void vtkShader::SetUniformParameter ( const char *  name,
int  numValues,
const int *  value 
)
protectedpure virtual

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

Implemented in vtkCgShader, and vtkGLSLShader.

virtual void vtkShader::SetUniformParameter ( const char *  name,
int  numValues,
const float *  value 
)
protectedpure virtual

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

Implemented in vtkCgShader, and vtkGLSLShader.

virtual void vtkShader::SetUniformParameter ( const char *  name,
int  numValues,
const double *  value 
)
protectedpure virtual

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

Implemented in vtkCgShader, and vtkGLSLShader.

virtual void vtkShader::SetMatrixParameter ( const char *  name,
int  numValues,
int  order,
const float *  value 
)
protectedpure virtual

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

Implemented in vtkCgShader, and vtkGLSLShader.

virtual void vtkShader::SetMatrixParameter ( const char *  name,
int  numValues,
int  order,
const double *  value 
)
protectedpure virtual

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

Implemented in vtkCgShader, and vtkGLSLShader.

virtual void vtkShader::SetMatrixParameter ( const char *  name,
const char *  state_matix_type,
const char *  transform_type 
)
protectedpure virtual

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

Implemented in vtkCgShader, and vtkGLSLShader.

virtual void vtkShader::SetSamplerParameter ( const char *  name,
vtkTexture texture,
int  textureIndex 
)
protectedpure 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 vtkCgShader, and vtkGLSLShader.


Member Data Documentation

vtkXMLShader* vtkShader::XMLShader
protected

Definition at line 137 of file vtkShader.h.

vtkShaderInternals* vtkShader::Internals
protected

Definition at line 138 of file vtkShader.h.

vtkTimeStamp vtkShader::PassShaderVariablesTime
protected

Definition at line 210 of file vtkShader.h.


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