Skip to main content

Module: utils/gl

Interfaces

Functions

clear

โ–ธ clear(gl, color?): void

Clears the color and depth buffer of the webgl context.

Parameters

NameTypeDescription
glWebGL2RenderingContextThe webgl context to clear
colorColorThe 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

NameTypeDescription
glWebGL2RenderingContextThe webgl context to use when creating the program
vertexShaderWebGLShaderThe vertex shader of the program
fragmentShaderWebGLShaderThe 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

NameTypeDescription
glWebGL2RenderingContextThe webgl context to use when creating the shader
typenumberThe type of shader to create (either gl.VERTEX_SHADER or gl.FRAGMENT_SHADER)
sourcestringThe 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

NameTypeDescription
glWebGL2RenderingContextThe webgl context to use when creating the shaders
vsSourcestringThe source of the vertex shader as a string
fsSourcestringThe 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

NameTypeDescription
glWebGL2RenderingContextThe {@link WebGL2RenderingContext} to use to load the texture
textureUnitTextureUnitThe 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