VTK  9.1.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
vtkShaderProgram Class Reference

The ShaderProgram uses one or more Shader objects. More...

#include <vtkShaderProgram.h>

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

Classes

struct  cmp_str
 

Public Types

enum  NormalizeOption { Normalize , NoNormalize }
 Options for attribute normalization. More...
 
typedef vtkObject Superclass
 

Public Member Functions

virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
vtkShaderProgramNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
std::string GetMD5Hash () const
 Set/Get the md5 hash of this program. More...
 
void SetMD5Hash (const std::string &hash)
 
bool isBound () const
 Check if the program is currently bound, or not. More...
 
void ReleaseGraphicsResources (vtkWindow *win)
 release any graphics resources this class is using. More...
 
int GetHandle () const
 Get the handle of the shader program. More...
 
std::string GetError () const
 Get the error message (empty if none) for the shader program. More...
 
bool EnableAttributeArray (const char *name)
 Enable the named attribute array. More...
 
bool DisableAttributeArray (const char *name)
 Disable the named attribute array. More...
 
bool UseAttributeArray (const char *name, int offset, size_t stride, int elementType, int elementTupleSize, NormalizeOption normalize)
 Use the named attribute array with the bound BufferObject. More...
 
template<class T >
bool SetAttributeArray (const char *name, const T &array, int tupleSize, NormalizeOption normalize)
 Upload the supplied array of tightly packed values to the named attribute. More...
 
bool SetUniformi (const char *name, int v)
 Set the name uniform value to int v. More...
 
bool SetUniformf (const char *name, float v)
 
bool SetUniform2i (const char *name, const int v[2])
 
bool SetUniform2f (const char *name, const float v[2])
 
bool SetUniform3f (const char *name, const float v[3])
 
bool SetUniform3f (const char *name, const double v[3])
 
bool SetUniform4f (const char *name, const float v[4])
 
bool SetUniform3uc (const char *name, const unsigned char v[3])
 
bool SetUniform4uc (const char *name, const unsigned char v[4])
 
bool SetUniformMatrix (const char *name, vtkMatrix3x3 *v)
 
bool SetUniformMatrix (const char *name, vtkMatrix4x4 *v)
 
bool SetUniformMatrix3x3 (const char *name, float *v)
 
bool SetUniformMatrix4x4 (const char *name, float *v)
 
bool SetUniform1iv (const char *name, const int count, const int *f)
 Set the name uniform array to f with count elements. More...
 
bool SetUniform1fv (const char *name, const int count, const float *f)
 
bool SetUniform2fv (const char *name, const int count, const float *f)
 
bool SetUniform2fv (const char *name, const int count, const float(*f)[2])
 
bool SetUniform3fv (const char *name, const int count, const float *f)
 
bool SetUniform3fv (const char *name, const int count, const float(*f)[3])
 
bool SetUniform4fv (const char *name, const int count, const float *f)
 
bool SetUniform4fv (const char *name, const int count, const float(*f)[4])
 
bool SetUniformMatrix4x4v (const char *name, const int count, float *v)
 
virtual void SetNumberOfOutputs (unsigned int)
 
bool IsUniformUsed (const char *)
 methods to inquire as to what uniforms/attributes are used by this shader. More...
 
bool IsAttributeUsed (const char *name)
 Return true if the compiled and linked shader has an attribute matching name. More...
 
int FindUniform (const char *name)
 
int FindAttributeArray (const char *name)
 
virtual vtkShaderGetVertexShader ()
 Get the vertex shader for this program. More...
 
void SetVertexShader (vtkShader *)
 Get the vertex shader for this program. More...
 
virtual vtkShaderGetFragmentShader ()
 Get the fragment shader for this program. More...
 
void SetFragmentShader (vtkShader *)
 Get the fragment shader for this program. More...
 
virtual vtkShaderGetGeometryShader ()
 Get the geometry shader for this program. More...
 
void SetGeometryShader (vtkShader *)
 Get the geometry shader for this program. More...
 
virtual vtkTransformFeedbackGetTransformFeedback ()
 Get/Set a TransformFeedbackCapture object on this shader program. More...
 
void SetTransformFeedback (vtkTransformFeedback *tfc)
 Get/Set a TransformFeedbackCapture object on this shader program. More...
 
virtual bool GetCompiled ()
 Set/Get flag for if this program is compiled. More...
 
virtual void SetCompiled (bool)
 Set/Get flag for if this program is compiled. More...
 
virtual void CompiledOn ()
 Set/Get flag for if this program is compiled. More...
 
virtual void CompiledOff ()
 Set/Get flag for if this program is compiled. More...
 
 vtkSetFilePathMacro (FileNamePrefixForDebugging)
 When developing shaders, it's often convenient to tweak the shader and re-render incrementally. More...
 
 vtkGetFilePathMacro (FileNamePrefixForDebugging)
 When developing shaders, it's often convenient to tweak the shader and re-render incrementally. More...
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 Turn debugging output on. More...
 
virtual void DebugOff ()
 Turn debugging output off. More...
 
bool GetDebug ()
 Get the value of the debug flag. More...
 
void SetDebug (bool debugFlag)
 Set the value of the debug flag. More...
 
virtual void Modified ()
 Update the modification time for this object. More...
 
virtual vtkMTimeType GetMTime ()
 Return this object's modified time. More...
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
vtkTypeBool HasObserver (unsigned long event)
 
vtkTypeBool HasObserver (const char *event)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkCommandGetCommand (unsigned long tag)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObserver (vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Allow user to set the AbortFlagOn() with the return value of the callback method. More...
 
int InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
int InvokeEvent (const char *event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. More...
 
virtual vtkTypeBool IsA (const char *name)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
virtual vtkIdType GetNumberOfGenerationsFromBase (const char *name)
 Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
virtual void Delete ()
 Delete a VTK object. More...
 
virtual void FastDelete ()
 Delete a reference to this object. More...
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream. More...
 
virtual void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object). More...
 
virtual void UnRegister (vtkObjectBase *o)
 Decrease the reference count (release by another object). More...
 
int GetReferenceCount ()
 Return the current reference count of this object. More...
 
void SetReferenceCount (int)
 Sets the reference count. More...
 
bool GetIsInMemkind () const
 A local state flag that remembers whether this object lives in the normal or extended memory space. More...
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 

Static Public Member Functions

static vtkShaderProgramNew ()
 
static vtkTypeBool IsTypeOf (const char *type)
 
static vtkShaderProgramSafeDownCast (vtkObjectBase *o)
 
static bool Substitute (std::string &source, const std::string &search, const std::string &replace, bool all=true)
 perform in place string substitutions, indicate if a substitution was done this is useful for building up shader strings which typically involve lots of string substitutions. More...
 
static bool Substitute (vtkShader *shader, const std::string &search, const std::string &replace, bool all=true)
 Perform in-place string substitutions on the shader source string and indicate if one or all substitutions were done. More...
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void BreakOnError ()
 This method is called when vtkErrorMacro executes. More...
 
static void SetGlobalWarningDisplay (int val)
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOn ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOff ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static int GetGlobalWarningDisplay ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class. More...
 
static vtkIdType GetNumberOfGenerationsFromBaseType (const char *name)
 Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void SetMemkindDirectory (const char *directoryname)
 The name of a directory, ideally mounted -o dax, to memory map an extended memory space within. More...
 
static bool GetUsingMemkind ()
 A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space. More...
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkShaderProgram ()
 
 ~vtkShaderProgram () override
 
bool AttachShader (const vtkShader *shader)
 Attach the supplied shader to this program. More...
 
bool DetachShader (const vtkShader *shader)
 Detach the supplied shader from this program. More...
 
virtual int CompileShader ()
 Compile this shader program and attached shaders. More...
 
bool Link ()
 Attempt to link the shader program. More...
 
bool Bind ()
 Bind the program in order to use it. More...
 
void Release ()
 Releases the shader program from the current context. More...
 
bool SetAttributeArrayInternal (const char *name, void *buffer, int type, int tupleSize, NormalizeOption normalize)
 
void ClearMaps ()
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
 ~vtkObject () override
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
 These methods allow a command to exclusively grab all events. More...
 
void InternalReleaseFocus ()
 These methods allow a command to exclusively grab all events. More...
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void RegisterInternal (vtkObjectBase *, vtkTypeBool check)
 
virtual void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Protected Attributes

vtkShaderVertexShader
 
vtkShaderFragmentShader
 
vtkShaderGeometryShader
 
vtkTransformFeedbackTransformFeedback
 
std::string MD5Hash
 
int Handle
 
int VertexShaderHandle
 
int FragmentShaderHandle
 
int GeometryShaderHandle
 
bool Linked
 
bool Bound
 
bool Compiled
 
unsigned int NumberOfOutputs
 
std::string Error
 
std::map< const char *, int, cmp_strAttributeLocs
 
std::map< const char *, int, cmp_strUniformLocs
 
std::map< int, vtkMTimeTypeUniformGroupMTimes
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Friends

class vtkOpenGLShaderCache
 
class VertexArrayObject
 
enum  UniformGroups { CameraGroup , LightingGroup , UserGroup }
 Set/Get times that can be used to track when a set of uniforms was last updated. More...
 
void SetUniformGroupUpdateTime (int, vtkMTimeType tm)
 Set/Get times that can be used to track when a set of uniforms was last updated. More...
 
vtkMTimeType GetUniformGroupUpdateTime (int)
 Set/Get times that can be used to track when a set of uniforms was last updated. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from vtkObjectBase
static vtkMallocingFunction GetCurrentMallocFunction ()
 
static vtkReallocingFunction GetCurrentReallocFunction ()
 
static vtkFreeingFunction GetCurrentFreeFunction ()
 
static vtkFreeingFunction GetAlternateFreeFunction ()
 

Detailed Description

The ShaderProgram uses one or more Shader objects.

a glsl shader program

This class creates a Vertex or Fragment shader, that can be attached to a ShaderProgram in order to render geometry etc.

This class contains the vertex, fragment, geometry shaders that combine to make a shader program

Online Examples:

Definition at line 123 of file vtkShaderProgram.h.

Member Typedef Documentation

◆ Superclass

Definition at line 127 of file vtkShaderProgram.h.

Member Enumeration Documentation

◆ NormalizeOption

Options for attribute normalization.

Enumerator
Normalize 

The values range across the limits of the numeric type.

This option instructs the rendering engine to normalize them to the range [0.0, 1.0] for unsigned types, and [-1.0, 1.0] for signed types. For example, unsigned char values will be mapped so that 0 = 0.0, and 255 = 1.0. The resulting floating point numbers will be passed into the shader program.

NoNormalize 

The values should be used as-is. Do not perform any normalization.

Definition at line 178 of file vtkShaderProgram.h.

◆ UniformGroups

Set/Get times that can be used to track when a set of uniforms was last updated.

This can be used to reduce redundant SetUniformCalls

Enumerator
CameraGroup 
LightingGroup 
UserGroup 

Definition at line 371 of file vtkShaderProgram.h.

Constructor & Destructor Documentation

◆ vtkShaderProgram()

vtkShaderProgram::vtkShaderProgram ( )
protected

◆ ~vtkShaderProgram()

vtkShaderProgram::~vtkShaderProgram ( )
overrideprotected

Member Function Documentation

◆ New()

static vtkShaderProgram * vtkShaderProgram::New ( )
static

◆ IsTypeOf()

static vtkTypeBool vtkShaderProgram::IsTypeOf ( const char *  type)
static

◆ IsA()

virtual vtkTypeBool vtkShaderProgram::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 vtkObjectBase.

◆ SafeDownCast()

static vtkShaderProgram * vtkShaderProgram::SafeDownCast ( vtkObjectBase o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkShaderProgram::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkShaderProgram * vtkShaderProgram::NewInstance ( ) const

◆ PrintSelf()

void vtkShaderProgram::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
overridevirtual

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.

◆ GetVertexShader()

virtual vtkShader * vtkShaderProgram::GetVertexShader ( )
virtual

Get the vertex shader for this program.

◆ SetVertexShader()

void vtkShaderProgram::SetVertexShader ( vtkShader )

Get the vertex shader for this program.

◆ GetFragmentShader()

virtual vtkShader * vtkShaderProgram::GetFragmentShader ( )
virtual

Get the fragment shader for this program.

◆ SetFragmentShader()

void vtkShaderProgram::SetFragmentShader ( vtkShader )

Get the fragment shader for this program.

◆ GetGeometryShader()

virtual vtkShader * vtkShaderProgram::GetGeometryShader ( )
virtual

Get the geometry shader for this program.

◆ SetGeometryShader()

void vtkShaderProgram::SetGeometryShader ( vtkShader )

Get the geometry shader for this program.

◆ GetTransformFeedback()

virtual vtkTransformFeedback * vtkShaderProgram::GetTransformFeedback ( )
virtual

Get/Set a TransformFeedbackCapture object on this shader program.

◆ SetTransformFeedback()

void vtkShaderProgram::SetTransformFeedback ( vtkTransformFeedback tfc)

Get/Set a TransformFeedbackCapture object on this shader program.

◆ GetCompiled()

virtual bool vtkShaderProgram::GetCompiled ( )
virtual

Set/Get flag for if this program is compiled.

◆ SetCompiled()

virtual void vtkShaderProgram::SetCompiled ( bool  )
virtual

Set/Get flag for if this program is compiled.

◆ CompiledOn()

virtual void vtkShaderProgram::CompiledOn ( )
virtual

Set/Get flag for if this program is compiled.

◆ CompiledOff()

virtual void vtkShaderProgram::CompiledOff ( )
virtual

Set/Get flag for if this program is compiled.

◆ GetMD5Hash()

std::string vtkShaderProgram::GetMD5Hash ( ) const
inline

Set/Get the md5 hash of this program.

Definition at line 174 of file vtkShaderProgram.h.

◆ SetMD5Hash()

void vtkShaderProgram::SetMD5Hash ( const std::string &  hash)
inline

Definition at line 175 of file vtkShaderProgram.h.

◆ isBound()

bool vtkShaderProgram::isBound ( ) const
inline

Check if the program is currently bound, or not.

Returns
True if the program is bound, false otherwise.

Definition at line 197 of file vtkShaderProgram.h.

◆ ReleaseGraphicsResources()

void vtkShaderProgram::ReleaseGraphicsResources ( vtkWindow win)

release any graphics resources this class is using.

◆ GetHandle()

int vtkShaderProgram::GetHandle ( ) const
inline

Get the handle of the shader program.

Definition at line 205 of file vtkShaderProgram.h.

◆ GetError()

std::string vtkShaderProgram::GetError ( ) const
inline

Get the error message (empty if none) for the shader program.

Definition at line 208 of file vtkShaderProgram.h.

◆ EnableAttributeArray()

bool vtkShaderProgram::EnableAttributeArray ( const char *  name)

Enable the named attribute array.

Return false if the attribute array is not contained in the linked shader program.

◆ DisableAttributeArray()

bool vtkShaderProgram::DisableAttributeArray ( const char *  name)

Disable the named attribute array.

Return false if the attribute array is not contained in the linked shader program.

◆ UseAttributeArray()

bool vtkShaderProgram::UseAttributeArray ( const char *  name,
int  offset,
size_t  stride,
int  elementType,
int  elementTupleSize,
NormalizeOption  normalize 
)

Use the named attribute array with the bound BufferObject.

Parameters
nameof the attribute (as seen in the shader program).
offsetinto the bound BufferObject.
strideThe stride of the element access (i.e. the size of each element in the currently bound BufferObject). 0 may be used to indicate tightly packed data.
elementTypeTag identifying the memory representation of the element.
elementTupleSizeThe number of elements per vertex (e.g. a 3D position attribute would be 3).
normalizeIndicates the range used by the attribute data. See NormalizeOption for more information.
Returns
false if the attribute array does not exist.

◆ SetAttributeArray()

template<class T >
bool vtkShaderProgram::SetAttributeArray ( const char *  name,
const T &  array,
int  tupleSize,
NormalizeOption  normalize 
)

Upload the supplied array of tightly packed values to the named attribute.

BufferObject attributes should be preferred and this may be removed in future.

Parameters
nameAttribute name
arrayContainer of data. See note.
tupleSizeThe number of elements per vertex, e.g. a 3D coordinate array will have a tuple size of 3.
normalizeIndicates the range used by the attribute data. See NormalizeOption for more information.
Note
The T type must have tightly packed values of T::value_type accessible by reference via T::operator[]. Additionally, the standard size() and empty() methods must be implemented. The std::vector classes is an example of such a container.

◆ SetUniformi()

bool vtkShaderProgram::SetUniformi ( const char *  name,
int  v 
)

Set the name uniform value to int v.

◆ SetUniformf()

bool vtkShaderProgram::SetUniformf ( const char *  name,
float  v 
)

◆ SetUniform2i()

bool vtkShaderProgram::SetUniform2i ( const char *  name,
const int  v[2] 
)

◆ SetUniform2f()

bool vtkShaderProgram::SetUniform2f ( const char *  name,
const float  v[2] 
)

◆ SetUniform3f() [1/2]

bool vtkShaderProgram::SetUniform3f ( const char *  name,
const float  v[3] 
)

◆ SetUniform3f() [2/2]

bool vtkShaderProgram::SetUniform3f ( const char *  name,
const double  v[3] 
)

◆ SetUniform4f()

bool vtkShaderProgram::SetUniform4f ( const char *  name,
const float  v[4] 
)

◆ SetUniform3uc()

bool vtkShaderProgram::SetUniform3uc ( const char *  name,
const unsigned char  v[3] 
)

◆ SetUniform4uc()

bool vtkShaderProgram::SetUniform4uc ( const char *  name,
const unsigned char  v[4] 
)

◆ SetUniformMatrix() [1/2]

bool vtkShaderProgram::SetUniformMatrix ( const char *  name,
vtkMatrix3x3 v 
)

◆ SetUniformMatrix() [2/2]

bool vtkShaderProgram::SetUniformMatrix ( const char *  name,
vtkMatrix4x4 v 
)

◆ SetUniformMatrix3x3()

bool vtkShaderProgram::SetUniformMatrix3x3 ( const char *  name,
float *  v 
)

◆ SetUniformMatrix4x4()

bool vtkShaderProgram::SetUniformMatrix4x4 ( const char *  name,
float *  v 
)

◆ SetUniform1iv()

bool vtkShaderProgram::SetUniform1iv ( const char *  name,
const int  count,
const int *  f 
)

Set the name uniform array to f with count elements.

◆ SetUniform1fv()

bool vtkShaderProgram::SetUniform1fv ( const char *  name,
const int  count,
const float *  f 
)

◆ SetUniform2fv() [1/2]

bool vtkShaderProgram::SetUniform2fv ( const char *  name,
const int  count,
const float *  f 
)

◆ SetUniform2fv() [2/2]

bool vtkShaderProgram::SetUniform2fv ( const char *  name,
const int  count,
const float(*)  f[2] 
)

◆ SetUniform3fv() [1/2]

bool vtkShaderProgram::SetUniform3fv ( const char *  name,
const int  count,
const float *  f 
)

◆ SetUniform3fv() [2/2]

bool vtkShaderProgram::SetUniform3fv ( const char *  name,
const int  count,
const float(*)  f[3] 
)

◆ SetUniform4fv() [1/2]

bool vtkShaderProgram::SetUniform4fv ( const char *  name,
const int  count,
const float *  f 
)

◆ SetUniform4fv() [2/2]

bool vtkShaderProgram::SetUniform4fv ( const char *  name,
const int  count,
const float(*)  f[4] 
)

◆ SetUniformMatrix4x4v()

bool vtkShaderProgram::SetUniformMatrix4x4v ( const char *  name,
const int  count,
float *  v 
)

◆ SetNumberOfOutputs()

virtual void vtkShaderProgram::SetNumberOfOutputs ( unsigned int  )
virtual

◆ Substitute() [1/2]

static bool vtkShaderProgram::Substitute ( std::string &  source,
const std::string &  search,
const std::string &  replace,
bool  all = true 
)
static

perform in place string substitutions, indicate if a substitution was done this is useful for building up shader strings which typically involve lots of string substitutions.

Parameters
[in]sourceThe source code to perform substitutions on
[in]searchThe string to search for
[in]replaceThe string replacement
[in]allWhether to replace all matches or just the first one
Returns
A boolean indicating whether the replacement was successful

◆ Substitute() [2/2]

static bool vtkShaderProgram::Substitute ( vtkShader shader,
const std::string &  search,
const std::string &  replace,
bool  all = true 
)
static

Perform in-place string substitutions on the shader source string and indicate if one or all substitutions were done.

This is useful for building up shader strings which typically involve a lot of string substitutions.

Parameters
[in]shaderThe source shader object to perform substitutions on
[in]searchThe string to search for
[in]replaceThe string replacement
[in]allWhether to replace all matches or just the first one
Returns
A boolean indicating whether the replacement was successful

◆ IsUniformUsed()

bool vtkShaderProgram::IsUniformUsed ( const char *  )

methods to inquire as to what uniforms/attributes are used by this shader.

This can save some compute time if the uniforms or attributes are expensive to compute

◆ IsAttributeUsed()

bool vtkShaderProgram::IsAttributeUsed ( const char *  name)

Return true if the compiled and linked shader has an attribute matching name.

◆ vtkSetFilePathMacro()

vtkShaderProgram::vtkSetFilePathMacro ( FileNamePrefixForDebugging  )

When developing shaders, it's often convenient to tweak the shader and re-render incrementally.

This provides a mechanism to do the same. To debug any shader program, set FileNamePrefixForDebugging to a file path e.g. /tmp/myshaders. Subsequently, when Bind() is called on the shader program, it will check for files named <FileNamePrefixForDebugging>VS.glsl, <FileNamePrefixForDebugging>GS.glsl and <FileNamePrefixForDebugging>FS.glsl for vertex shader, geometry shader and fragment shader codes respectively. If a file doesn't exist, then it dumps out the current code to that file. If the file exists, then the shader is recompiled to use the contents of that file. Thus, after the files have been dumped in the first render, you can open the files in a text editor and update as needed. On following render, the modified contexts from the file will be used.

This is only intended for debugging during development and should not be used in production.

◆ vtkGetFilePathMacro()

vtkShaderProgram::vtkGetFilePathMacro ( FileNamePrefixForDebugging  )

When developing shaders, it's often convenient to tweak the shader and re-render incrementally.

This provides a mechanism to do the same. To debug any shader program, set FileNamePrefixForDebugging to a file path e.g. /tmp/myshaders. Subsequently, when Bind() is called on the shader program, it will check for files named <FileNamePrefixForDebugging>VS.glsl, <FileNamePrefixForDebugging>GS.glsl and <FileNamePrefixForDebugging>FS.glsl for vertex shader, geometry shader and fragment shader codes respectively. If a file doesn't exist, then it dumps out the current code to that file. If the file exists, then the shader is recompiled to use the contents of that file. Thus, after the files have been dumped in the first render, you can open the files in a text editor and update as needed. On following render, the modified contexts from the file will be used.

This is only intended for debugging during development and should not be used in production.

◆ SetUniformGroupUpdateTime()

void vtkShaderProgram::SetUniformGroupUpdateTime ( int  ,
vtkMTimeType  tm 
)

Set/Get times that can be used to track when a set of uniforms was last updated.

This can be used to reduce redundant SetUniformCalls

◆ GetUniformGroupUpdateTime()

vtkMTimeType vtkShaderProgram::GetUniformGroupUpdateTime ( int  )

Set/Get times that can be used to track when a set of uniforms was last updated.

This can be used to reduce redundant SetUniformCalls

◆ FindUniform()

int vtkShaderProgram::FindUniform ( const char *  name)

◆ FindAttributeArray()

int vtkShaderProgram::FindAttributeArray ( const char *  name)

◆ AttachShader()

bool vtkShaderProgram::AttachShader ( const vtkShader shader)
protected

Attach the supplied shader to this program.

Note
A maximum of one Vertex shader and one Fragment shader can be attached to a shader program.
Returns
true on success.

◆ DetachShader()

bool vtkShaderProgram::DetachShader ( const vtkShader shader)
protected

Detach the supplied shader from this program.

Note
A maximum of one Vertex shader and one Fragment shader can be attached to a shader program.
Returns
true on success.

◆ CompileShader()

virtual int vtkShaderProgram::CompileShader ( )
protectedvirtual

Compile this shader program and attached shaders.

◆ Link()

bool vtkShaderProgram::Link ( )
protected

Attempt to link the shader program.

Returns
false on failure. Query error to get the reason.
Note
The shaders attached to the program must have been compiled.

◆ Bind()

bool vtkShaderProgram::Bind ( )
protected

Bind the program in order to use it.

If the program has not been linked then link() will be called.

◆ Release()

void vtkShaderProgram::Release ( )
protected

Releases the shader program from the current context.

◆ SetAttributeArrayInternal()

bool vtkShaderProgram::SetAttributeArrayInternal ( const char *  name,
void *  buffer,
int  type,
int  tupleSize,
NormalizeOption  normalize 
)
protected

◆ ClearMaps()

void vtkShaderProgram::ClearMaps ( )
protected

Friends And Related Function Documentation

◆ vtkOpenGLShaderCache

friend class vtkOpenGLShaderCache
friend

Definition at line 396 of file vtkShaderProgram.h.

◆ VertexArrayObject

friend class VertexArrayObject
friend

Definition at line 471 of file vtkShaderProgram.h.

Member Data Documentation

◆ VertexShader

vtkShader* vtkShaderProgram::VertexShader
protected

Definition at line 436 of file vtkShaderProgram.h.

◆ FragmentShader

vtkShader* vtkShaderProgram::FragmentShader
protected

Definition at line 437 of file vtkShaderProgram.h.

◆ GeometryShader

vtkShader* vtkShaderProgram::GeometryShader
protected

Definition at line 438 of file vtkShaderProgram.h.

◆ TransformFeedback

vtkTransformFeedback* vtkShaderProgram::TransformFeedback
protected

Definition at line 439 of file vtkShaderProgram.h.

◆ MD5Hash

std::string vtkShaderProgram::MD5Hash
protected

Definition at line 442 of file vtkShaderProgram.h.

◆ Handle

int vtkShaderProgram::Handle
protected

Definition at line 446 of file vtkShaderProgram.h.

◆ VertexShaderHandle

int vtkShaderProgram::VertexShaderHandle
protected

Definition at line 447 of file vtkShaderProgram.h.

◆ FragmentShaderHandle

int vtkShaderProgram::FragmentShaderHandle
protected

Definition at line 448 of file vtkShaderProgram.h.

◆ GeometryShaderHandle

int vtkShaderProgram::GeometryShaderHandle
protected

Definition at line 449 of file vtkShaderProgram.h.

◆ Linked

bool vtkShaderProgram::Linked
protected

Definition at line 451 of file vtkShaderProgram.h.

◆ Bound

bool vtkShaderProgram::Bound
protected

Definition at line 452 of file vtkShaderProgram.h.

◆ Compiled

bool vtkShaderProgram::Compiled
protected

Definition at line 453 of file vtkShaderProgram.h.

◆ NumberOfOutputs

unsigned int vtkShaderProgram::NumberOfOutputs
protected

Definition at line 459 of file vtkShaderProgram.h.

◆ Error

std::string vtkShaderProgram::Error
protected

Definition at line 461 of file vtkShaderProgram.h.

◆ AttributeLocs

std::map<const char*, int, cmp_str> vtkShaderProgram::AttributeLocs
protected

Definition at line 466 of file vtkShaderProgram.h.

◆ UniformLocs

std::map<const char*, int, cmp_str> vtkShaderProgram::UniformLocs
protected

Definition at line 467 of file vtkShaderProgram.h.

◆ UniformGroupMTimes

std::map<int, vtkMTimeType> vtkShaderProgram::UniformGroupMTimes
protected

Definition at line 469 of file vtkShaderProgram.h.


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