Skip to content

ShaderProgram

Overview

Abstraction over the shader program

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class ShaderProgram

import { ShaderProgram } from 'scenerystack/scenery';

Constructor

new ShaderProgram( gl : WebGLRenderingContext, vertexSource : string, fragmentSource : string, providedOptions? : ShaderProgramOptions )

Instance Methods

initialize( gl : WebGLRenderingContext )

Initializes (or reinitializes) the WebGL state and uniform/attribute references.

use()

activateAttribute( attributeName : string )

enableVertexAttribArray( attributeName : string )

unuse()

disableVertexAttribArray( attributeName : string )

deactivateAttribute( attributeName : string )

dispose()

Releases references

Instance Properties

uniformLocations : Record<string, WebGLUniformLocation>

attributeLocations : Record<string, number>

activeAttributes : Record<string, boolean>

Type ShaderProgramOptions

import type { ShaderProgramOptions } from 'scenerystack/scenery';
  • attributes?: string[]
    (vertex) attribute names in the shader source
  • uniforms?: string[]
    uniform names in the shader source

Source Code

See the source for ShaderProgram.ts in the scenery repository.