VTK
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
vtkCgShader Class Reference

Cg Shader. More...

#include <vtkCgShader.h>

Inheritance diagram for vtkCgShader:
[legend]
Collaboration diagram for vtkCgShader:
[legend]

List of all members.

Public Types

typedef vtkShader Superclass
- Public Types inherited from vtkShader
- Public Types inherited from vtkObject

Public Member Functions

virtual const char * GetClassName ()
virtual int IsA (const char *type)
void PrintSelf (ostream &os, vtkIndent indent)
virtual int Compile ()
virtual void Bind ()
virtual void Unbind ()
void ReportError ()
void ReleaseGraphicsResources (vtkWindow *)
- Public Member Functions inherited from vtkShader
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)
int GetScope ()
- 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 vtkCgShaderNew ()
static int IsTypeOf (const char *type)
static vtkCgShaderSafeDownCast (vtkObject *o)

Protected Member Functions

virtual void SetSamplerParameter (const char *name, vtkTexture *texture, int)
virtual void SetUniformParameter (const char *name, int numValues, const int *value)
virtual void SetUniformParameter (const char *name, int numValues, const float *value)
virtual void SetUniformParameter (const char *name, int numValues, const double *value)
virtual void SetMatrixParameter (const char *name, int numValues, int order, const float *value)
virtual void SetMatrixParameter (const char *name, int numValues, int order, const double *value)
virtual void SetMatrixParameter (const char *name, const char *state_matix_type, const char *transform_type)
- Protected Member Functions inherited from vtkShader
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 *)
 vtkShader ()
 ~vtkShader ()
- 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 &)

Friends

class vtkCgShaderDeviceAdapter
virtual void PassShaderVariables (vtkActor *actor, vtkRenderer *ren)
 vtkCgShader ()
 ~vtkCgShader ()

Additional Inherited Members

- Protected Types inherited from vtkShader
enum  MatrixOrders { RowMajor, ColumnMajor }
- Protected Attributes inherited from vtkShader
vtkXMLShaderXMLShader
vtkTimeStamp PassShaderVariablesTime
- Protected Attributes inherited from vtkObject
unsigned char Debug
vtkTimeStamp MTime
vtkSubjectHelper * SubjectHelper
- Protected Attributes inherited from vtkObjectBase
int ReferenceCount
vtkWeakPointerBase ** WeakPointers

Detailed Description

Cg Shader.

vtkCgShader is the only class that interfaces directly with the Cg libraries. Once is has a valid shader described by a vtkXMLDataElement it will create, compile, install, and initialize the parameters of a Cg hardware shader.

Supported Shader Types::
Basic Types: uniform float uniform double
Supported Shader Types::
Vector Types: uniform float{1|2|3|4} uniform double{1|2|3|4}
Supported Shader Types::
Matrix Types: uniform float{1|2|3|4}x{1|2|3|4} uniform double{1|2|3|4}x{1|2|3|4}
Supported Shader Types::
NOTE: In the above, 'double' and 'float' refer to the application's representation, the hardware shader must define all of the above types as 'uniform float'.
Supported Shader Types::
State Matrix Parameters: uniform float4x4 with the following Cg-defined settings: CG_GL_MATRIX_IDENTITY CG_GL_MATRIX_TRANSPOSE CG_GL_MATRIX_INVERSE CG_GL_MATRIX_INVERSE_TRANSPOSE CG_GL_MODELVIEW_MATRIX CG_GL_PROJECTION_MATRIX CG_GL_TEXTURE_MATRIX CG_GL_MODELVIEW_PROJECTION_MATRIX
Supported Shader Types::
Texture Samplers: sample1D - Not tested sample2D sample3D - Not supported by VTK sampleRECT - Not supported by VTK sampleCUBE - Not supported by VTK
Supported Shader Types::
User-Defined: uniform struct
Supported Shader Types::
VTK-Specific Hardware Data Structures: vtkProperty vtkLight vtkCamera See vtkSNL/Rendering/Shaders/vtkProperty.cg See vtkSNL/Rendering/Shaders/vtkLight.cg See vtkSNL/Rendering/Shaders/vtkCamera.cg
Thanks:
Shader support in VTK includes key contributions by Gary Templet at Sandia National Labs.

Definition at line 106 of file vtkCgShader.h.


Member Typedef Documentation

Reimplemented from vtkShader.

Definition at line 110 of file vtkCgShader.h.


Constructor & Destructor Documentation

vtkCgShader::vtkCgShader ( )
protected

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. We override this method for Cg shaders, since for Cg shaders, we need to ensure that the actor transformations are pushed before state matrix uniform variables are bound.

vtkCgShader::~vtkCgShader ( )
protected

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. We override this method for Cg shaders, since for Cg shaders, we need to ensure that the actor transformations are pushed before state matrix uniform variables are bound.


Member Function Documentation

static vtkCgShader* vtkCgShader::New ( )
static

Create an object with Debug turned off, modified time initialized to zero, and reference counting on.

Reimplemented from vtkObject.

virtual const char* vtkCgShader::GetClassName ( )
virtual

Reimplemented from vtkShader.

static int vtkCgShader::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 vtkShader.

virtual int vtkCgShader::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 vtkShader.

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

Reimplemented from vtkShader.

void vtkCgShader::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 vtkShader.

virtual int vtkCgShader::Compile ( )
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.

Implements vtkShader.

virtual void vtkCgShader::Bind ( )
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.

Reimplemented from vtkShader.

virtual void vtkCgShader::Unbind ( )
virtual

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

Reimplemented from vtkShader.

void vtkCgShader::ReportError ( )

Internal method don't call directly. Called by Cg erro callback to report Cg errors.

void vtkCgShader::ReleaseGraphicsResources ( vtkWindow )
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 from vtkShader.

virtual void vtkCgShader::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. We override this method for Cg shaders, since for Cg shaders, we need to ensure that the actor transformations are pushed before state matrix uniform variables are bound.

Reimplemented from vtkShader.

virtual void vtkCgShader::SetUniformParameter ( const char *  name,
int  numValues,
const int *  value 
)
protectedvirtual

Equivalent to cgGLSetParameter and glUniform.

Implements vtkShader.

virtual void vtkCgShader::SetUniformParameter ( const char *  name,
int  numValues,
const float *  value 
)
protectedvirtual

Equivalent to cgGLSetParameter and glUniform.

Implements vtkShader.

virtual void vtkCgShader::SetUniformParameter ( const char *  name,
int  numValues,
const double *  value 
)
protectedvirtual

Equivalent to cgGLSetParameter and glUniform.

Implements vtkShader.

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

Equivalent to cgGLSetMatrixParameterfc and glUniformMatrix.

Implements vtkShader.

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

Equivalent to cgGLSetMatrixParameterfc and glUniformMatrix.

Implements vtkShader.

virtual void vtkCgShader::SetMatrixParameter ( const char *  name,
const char *  state_matix_type,
const char *  transform_type 
)
protectedvirtual

Equivalent to cgGLSetMatrixParameterfc and glUniformMatrix.

Implements vtkShader.

virtual void vtkCgShader::SetSamplerParameter ( const char *  name,
vtkTexture texture,
int  textureIndex 
)
protectedvirtual

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.

Implements vtkShader.


Friends And Related Function Documentation

friend class vtkCgShaderDeviceAdapter
friend

Definition at line 172 of file vtkCgShader.h.


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