Constructor
new ShaderProgram(name, material)
Shader program name.
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name | string | ShaderProgram name. | |||||||||||||||
material | ProgramMaterial | Object stores uniforms, attributes and program codes: Properties
|
- Source
Methods
activate() → {ShaderProgram}
Activates this shader program and disables previously active one.
- Source
- Type:
- ShaderProgram
apply()
Applies currently stored shader variable values.
- Source
attach(handler) → {ShaderProgram}
Attaches this shader program to a handler.
| Name | Type | Description |
|---|---|---|
handler | Handler | WebGL handler. |
- Source
- Type:
- ShaderProgram
createProgram(gl)
Compiles shaders, links WebGL program and resolves variable locations.
| Name | Type | Description |
|---|---|---|
gl | WebGL2RenderingContext | WebGL context. |
- Source
deactivate() → {ShaderProgram}
Deactivates this shader program.
- Source
- Type:
- ShaderProgram
delete()
Deletes underlying WebGL program.
- Source
disableAttribArrays()
Disables all attribute arrays used by this shader program.
- Source
drawArrays(mode, numItems) → {ShaderProgram}
Draws non-indexed geometry.
| Name | Type | Description |
|---|---|---|
mode | number | WebGL draw mode. |
numItems | number | Vertex count to draw. |
- Source
- Type:
- ShaderProgram
drawIndexBuffer(mode, buffer) → {ShaderProgram}
Draws indexed geometry from provided index buffer.
| Name | Type | Description |
|---|---|---|
mode | number | WebGL draw mode. |
buffer | WebGLBufferExt | Index buffer. |
- Source
- Type:
- ShaderProgram
enableAttribArrays()
Enables all attribute arrays used by this shader program.
- Source
initialize() → {ShaderProgram}
Initializes this shader program using handler WebGL context.
- Source
- Type:
- ShaderProgram
isActive() → {boolean}
Returns true if this shader program is active.
- Source
- Type:
- boolean
remove()
Removes this shader program from its handler and releases WebGL program.
- Source
set(material) → {ShaderProgram}
Sets provided shader variables and applies them. Automatically activates this shader program.
| Name | Type | Description |
|---|---|---|
material | Record.<string, any> | Variable values by variable name. |
- Source
- Type:
- ShaderProgram
use()
Makes this shader program current in WebGL context.
- Source
(static) bindBuffer(program, variable)
Binds attribute buffer and sets its pointer.
| Name | Type | Description |
|---|---|---|
program | ShaderProgram | Shader program instance. |
variable | ProgramVariable | Attribute variable descriptor. |
- Source