tubugl-core

Program

Usage

Create Program

let {Program} = require( 'tubugl-core' );

// make program with vertexShaderSrc and fragmentShaderSrc
let program  = new Program( gl, vertexShaderSrc, fragmentShaderSrc )

use program

// use program
program.use();

update uniform

// update uniform
let uColorUniform = program.getUniforms('uColor');
gl.uniform3f(uColorUniform.location, 1.0, 0.0, 0.0);

// update uniform
program.uniform['uColor'].update(1.0, 0.0, 0.0);

set texture as uniform

texture.activeTexture().bind();

program.setUniformTexture(texture, 'uTexture');

enable attribute

// positionAttibute is the object made from ArrayBuffer
positionAttibute.bind().attribPointer(program);