Skip to content

ShaderCache ​

Methods ​

bindShaderProgram ​

Bind the given program, releasing the previously bound one.

ArgumentTypeRequiredDescription
programYesThe program to bind.

Returns ​

TypeDescription
number1 always.

extend ​

Method used to decorate a given object (publicAPI+model) with vtkShaderCache characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIShaderCacheInitialValuesNo(default: {})

getContext ​

Get the WebGL context.

getLastShaderProgramBound ​

Get the last bound program.

getOpenGLRenderWindow ​

Get the OpenGL render window this cache belongs to.

getShaderProgram ​

Get the cached program for the given sources, creating it when missing. The sources are used as given: they are not substituted.

ArgumentTypeRequiredDescription
vertexCodeYesThe vertex shader source.
fragmentCodeYesThe fragment shader source.
geometryCodeYesThe geometry shader source.

newInstance ​

Method used to create a new instance of vtkShaderCache.

ArgumentTypeRequiredDescription
initialValuesIShaderCacheInitialValuesNofor pre-setting some of its content

readyShaderProgram ​

Compile and bind the given program if needed.

ArgumentTypeRequiredDescription
programYesThe program to ready.

Returns ​

TypeDescription
Nullable<vtkShaderProgram>The program, or null on failure.

readyShaderProgramArray ​

Get, compile and bind the program matching the given sources.

ArgumentTypeRequiredDescription
vertexCodeYesThe vertex shader source.
fragmentCodeYesThe fragment shader source.
geometryCodeYesThe geometry shader source.

Returns ​

TypeDescription
Nullable<vtkShaderProgram>The ready program, or null on failure.

releaseCurrentShaderProgram ​

Release the currently bound program, if any.

releaseGraphicsResources ​

Release every program this cache created and empty the cache.

replaceShaderValues ​

Apply the WebGL2 system replacements to the given shader sources.

ArgumentTypeRequiredDescription
VSSourceYesThe vertex shader source.
FSSourceYesThe fragment shader source.
GSSourceYesThe geometry shader source.

Returns ​

TypeDescription
IShaderCacheSourcesThe substituted sources.

setContext ​

Set the WebGL context.

ArgumentTypeRequiredDescription
contextYesThe WebGL context.

setLastShaderProgramBound ​

Set the last bound program.

ArgumentTypeRequiredDescription
lastShaderProgramBoundYesThe program.

setOpenGLRenderWindow ​

Set the OpenGL render window this cache belongs to.

ArgumentTypeRequiredDescription
openGLRenderWindowYesThe OpenGL render window.