ShaderCache
Methods
bindShaderProgram
Bind the given program, releasing the previously bound one.
| Argument | Type | Required | Description |
|---|---|---|---|
program | Yes | The program to bind. |
Returns
| Type | Description |
|---|---|
| number | 1 always. |
extend
Method used to decorate a given object (publicAPI+model) with vtkShaderCache characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IShaderCacheInitialValues | No | (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.
| Argument | Type | Required | Description |
|---|---|---|---|
vertexCode | Yes | The vertex shader source. | |
fragmentCode | Yes | The fragment shader source. | |
geometryCode | Yes | The geometry shader source. |
newInstance
Method used to create a new instance of vtkShaderCache.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IShaderCacheInitialValues | No | for pre-setting some of its content |
readyShaderProgram
Compile and bind the given program if needed.
| Argument | Type | Required | Description |
|---|---|---|---|
program | Yes | The program to ready. |
Returns
| Type | Description |
|---|---|
| Nullable<vtkShaderProgram> | The program, or null on failure. |
readyShaderProgramArray
Get, compile and bind the program matching the given sources.
| Argument | Type | Required | Description |
|---|---|---|---|
vertexCode | Yes | The vertex shader source. | |
fragmentCode | Yes | The fragment shader source. | |
geometryCode | Yes | The geometry shader source. |
Returns
| Type | Description |
|---|---|
| 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.
| Argument | Type | Required | Description |
|---|---|---|---|
VSSource | Yes | The vertex shader source. | |
FSSource | Yes | The fragment shader source. | |
GSSource | Yes | The geometry shader source. |
Returns
| Type | Description |
|---|---|
| IShaderCacheSources | The substituted sources. |
setContext
Set the WebGL context.
| Argument | Type | Required | Description |
|---|---|---|---|
context | Yes | The WebGL context. |
setLastShaderProgramBound
Set the last bound program.
| Argument | Type | Required | Description |
|---|---|---|---|
lastShaderProgramBound | Yes | The program. |
setOpenGLRenderWindow
Set the OpenGL render window this cache belongs to.
| Argument | Type | Required | Description |
|---|---|---|---|
openGLRenderWindow | Yes | The OpenGL render window. |