Constructor
new ShaderProgram(vertexSource, fragmentSource, uniforms)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
vertexSource |
String | vertex shader glsl string |
fragmentSource |
String | vertex shader glsl string |
uniforms |
Object.<String, Uniform> | (optional) uniforms for this program. |
Members
(readonly) attributeLocations :Object.<string, number>
- Source:
cache for attribute locations to avoid looking them up by webgl every time
Type:
- Object.<string, number>
blendDST :String
- Source:
- Default Value:
- 'ONE'
gl blending destination factor
Type:
- String
blendSRC :String
- Source:
- Default Value:
- 'ONE'
gl blending source factor
Type:
- String
cullFace :String
- Source:
- Default Value:
- 'BACK'
Face culling mode
Type:
- String
depthFunc :String
- Source:
- Default Value:
- 'LEQUAL'
Depth sorting function
Type:
- String
enableBlending :Boolean
- Source:
- Default Value:
- false
Enable or disable gl.BLEND feature
Type:
- Boolean
enableCulling :Boolean
- Source:
- Default Value:
- true
Enable or disable gl.CULL_FACE
Type:
- Boolean
enableDepth :Boolean
- Source:
- Default Value:
- true
Enable or disable gl.DEPTH_SORT feature
Type:
- Boolean
fragmentShader :WebGLShader
- Source:
gl shader object
Type:
- WebGLShader
fragmentSource :String
- Source:
glsl source code for fragment shader
Type:
- String
(readonly) isCompiled :Boolean
- Source:
used internally to check if shaders have been compiled yet
Type:
- Boolean
program :WebGLProgram
- Source:
gl program object
Type:
- WebGLProgram
(readonly) textureUnit :Number
- Source:
Used internally to keep track of texture units while assigning texture uniforms.
Type:
- Number
(readonly) uniformLocations :Object.<String, number>
- Source:
cache for uniforms locations to avoid looking them up by webgl every time
Type:
- Object.<String, number>
uniforms :Object.<String, Uniform>
- Source:
uniforms for this shader program
Type:
- Object.<String, Uniform>
vertexShader :WebGLShader
- Source:
gl shader object
Type:
- WebGLShader
vertexSource :String
- Source:
glsl source code for vertex shader
Type:
- String
Methods
compile(gl)
- Source:
Creates webgl shader and program objects.
Assigns shader sources to them.
Compiles shaders, attaches them to program and links the program.
This is called from ShaderProgram#use if ShaderProgram#isCompiled is false.
Assigns shader sources to them.
Compiles shaders, attaches them to program and links the program.
This is called from ShaderProgram#use if ShaderProgram#isCompiled is false.
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebGLRenderingContext |
use(gl)
- Source:
Sets this program to be active.
and sets blending mode, depth sort mode and face culling mode. Also compiles the shaders if they are not compiled already.
and sets blending mode, depth sort mode and face culling mode. Also compiles the shaders if they are not compiled already.
Parameters:
Name | Type | Description |
---|---|---|
gl |
WebGLRenderingContext |