Program

Represents more comfortable using WebGL shader program.

Constructor

new Program(name, material)

Parameters:
NameTypeDescription
namestring

Program name.

materialProgramMaterial

Object stores uniforms, attributes and program codes:

Properties
NameTypeDescription
uniformsRecord.<string, any>

Uniforms definition section.

attributesRecord.<string, any>

Attributes definition section.

vertexShaderstring

Vertex glsl code.

fragmentShaderstring

Fragment glsl code.

Methods

apply()

Apply current variables.

createProgram(gl)

Creates program.

Parameters:
NameTypeDescription
glObject

WebGl context.

delete()

Delete program.

disableAttribArrays()

Disable current program vertexAttribArrays.

drawArrays(mode, numItems)

Calls drawArrays function.

Parameters:
NameTypeDescription
modenumber

Draw mode GL_TRIANGLES, GL_LINESTRING, etc.

numItemsnumber

Items to draw

drawIndexBuffer(mode, buffer)

Calls drawElements index buffer function.

Parameters:
NameTypeDescription
modenumber

Draw mode(GL_TRIANGLES, GL_LINESTRING etc.).

bufferObject

Index buffer.

enableAttribArrays()

Enable current program vertexAttribArrays.

set(material)

Sets program variables.

Parameters:
NameTypeDescription
materialObject

Variables and values object.

use()

Sets the current program frame.

(static) bindBuffer(program, variable)

Bind program buffer.

Parameters:
NameTypeDescription
programProgram

Used program.

variableObject

Variable represents buffer data.