WebGLProgramWrapper
Wrapper for a WebGL program, containing all the information that was used to create it.
A WebGLProgram should never be exposed outside the WebGLRenderer, so the WebGLRenderer
can handle context loss and other events without other systems having to be aware of it.
Always use WebGLProgramWrapper instead.
Constructor
new WebGLProgramWrapper(renderer, vertexSource, fragmentShader)
Parameters
| name | type | optional | description |
|---|---|---|---|
| renderer | Phaser.Renderer.WebGL.WebGLRenderer | No | The WebGLRenderer instance that owns this wrapper. |
| vertexSource | string | No | The vertex shader source code as a string. |
| fragmentShader | string | No | The fragment shader source code as a string. |
Scope: static
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L26
Since: 3.80.0
Public Members
compileTimeMs
compileTimeMs: number
Description:
The time taken to compile this program, in milliseconds.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L96
Since: 4.0.0
compiling
compiling: boolean
Description:
Whether this program is currently being compiled.
This will always be false, unless parallel shader compilation
is enabled via config.render.skipUnreadyShaders.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L72
Since: 4.0.0
fragmentSource
fragmentSource: string
Description:
The fragment shader source code as a string.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L126
Since: 3.80.0
glAttributeBuffer
glAttributeBuffer: WebGLBuffer
Description:
The buffer which this program is using for its attributes.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L178
Since: 4.0.0
glAttributeNames
glAttributeNames: Map.<string, number>
Description:
Map of attribute names to their indexes in glAttributes.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L169
Since: 4.0.0
glAttributes
glAttributes: Array.<{location: GLint, name: string, size: number, type: GLenum}>
Description:
The attribute state of this program.
These represent the actual state in WebGL, and are only updated when
the program is used to draw.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L157
Since: 4.0.0
glState
glState: Phaser.Types.Renderer.WebGL.WebGLGlobalParameters
Description:
The WebGL state necessary to bind this program.
This is used internally to accelerate state changes.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L106
Since: 4.0.0
glUniforms
glUniforms: Map.<string, Phaser.Types.Renderer.WebGL.WebGLUniform>
Description:
The uniform state of this program.
These represent the actual state in WebGL, and are only updated when
the program is used to draw.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L188
Since: 4.0.0
renderer
renderer: Phaser.Renderer.WebGL.WebGLRenderer
Description:
The WebGLRenderer instance that owns this wrapper.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L49
Since: 4.0.0
uniformRequests
uniformRequests: Map.<string, any>
Description:
Requests to update the uniform state.
Set a request by name to a new value.
These are only processed when the program is used to draw.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L200
Since: 4.0.0
vertexSource
vertexSource: string
Description:
The vertex shader source code as a string.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L117
Since: 3.80.0
webGLProgram
webGLProgram: WebGLProgram
Description:
The WebGLProgram being wrapped by this class.
This property could change at any time.
Therefore, you should never store a reference to this value.
It should only be passed directly to the WebGL API for drawing.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L58
Since: 3.80.0
Public Methods
bind
<instance> bind()
Description:
Set this program as the active program in the WebGL context.
This will also update the uniform state.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L431
Since: 4.0.0
checkParallelCompile
<instance> checkParallelCompile()
Description:
Poll shader compilation status, and complete the program if it is ready.
This is only called if skipUnreadyShaders is enabled
and the KHR_parallel_shader_compile extension is available.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L280
Since: 4.0.0
createResource
<instance> createResource()
Description:
Creates a WebGLProgram from the given vertex and fragment shaders.
This is called automatically by the constructor. It may also be
called again if the WebGLProgram needs re-creating.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L214
Since: 3.80.0
destroy
<instance> destroy()
Description:
Remove this WebGLProgram from the GL context.
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L532
Since: 3.80.0
setUniform
<instance> setUniform(name, value)
Description:
Set a uniform value for this WebGLProgram.
This method doesn't set the WebGL value directly.
Instead, it adds a request to the uniformRequests map.
These requests are processed when the program is used to draw.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| name | string | No | The name of the uniform. |
| value | number | Array.<number> | Int32Array | Float32Array |
Source: src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L414
Since: 4.0.0