Module: utils/gl
Interfaces
Functions
clear
โธ clear(gl
, color?
): void
Clears the color and depth buffer of the webgl context.
Parameters
Name | Type | Description |
---|---|---|
gl | WebGL2RenderingContext | The webgl context to clear |
color | Color | The color to use as the clear color |
Returns
void
Defined in
src/utils/gl.ts:88
createProgram
โธ createProgram(gl
, vertexShader
, fragmentShader
): WebGLProgram
Creates a {@link WebGLProgram} instance with a vertex and fragment shader.
Parameters
Name | Type | Description |
---|---|---|
gl | WebGL2RenderingContext | The webgl context to use when creating the program |
vertexShader | WebGLShader | The vertex shader of the program |
fragmentShader | WebGLShader | The fragment shader of the program |
Returns
WebGLProgram
The created program or undefined if there was an error when creating the program
Defined in
src/utils/gl.ts:51
createShader
โธ createShader(gl
, type
, source
): WebGLShader
Creates and compiles a shader from its source.
Parameters
Name | Type | Description |
---|---|---|
gl | WebGL2RenderingContext | The webgl context to use when creating the shader |
type | number | The type of shader to create (either gl.VERTEX_SHADER or gl.FRAGMENT_SHADER ) |
source | string | The shader source as a string |
Returns
WebGLShader
The compiled shader or undefined if there was an error when creating the shader
Defined in
src/utils/gl.ts:29
createShaderProgram
โธ createShaderProgram(gl
, vsSource
, fsSource
): WebGLProgram
Creates each webgl shader and links them together in a {@link WebGLProgram}
Parameters
Name | Type | Description |
---|---|---|
gl | WebGL2RenderingContext | The webgl context to use when creating the shaders |
vsSource | string | The source of the vertex shader as a string |
fsSource | string | The source of the fragment shader as a string |
Returns
WebGLProgram
The created {@link WebGLProgram} instance
Defined in
src/utils/gl.ts:74
loadTexture
โธ loadTexture(gl
, textureUnit
): WebGLTexture
Creates a {@link WebGLTexture} and loads an image onto it.
Parameters
Name | Type | Description |
---|---|---|
gl | WebGL2RenderingContext | The {@link WebGL2RenderingContext} to use to load the texture |
textureUnit | TextureUnit | The texture unit to to take the Texture from and to bind the {@link WebGLTexture} to |
Returns
WebGLTexture
The WebGL texture that was created
Defined in
src/utils/gl.ts:100