WebGL shader wrapper.
$ npm install --save @vaalentin/gl-shader
import Shader from '@vaalentin/gl-shader';
// setup canvas and gl
const vertexShader = new Shader(gl, gl.VERTEX_SHADER,
`
attribute vec3 aPos;
void main() {
gl_Position = vec4(aPos, 1.0);
}
`);
Create a new shader, where:
gl
is the WebGL context.type
is the shader type:gl.VERTEX_SHADER
orgl.FRAGMENT_SHADER
.src
is the shader source, as astring
.
Delete instance. Calls gl.deleteShader
.
MIT, see LICENSE.md for more details.
Thanks to the amazing stackgl for the inspiration.