Skip to content

ahmerhh/WebGraphicLibrary-shader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebGraphicLibrary-shader

WebGL shader wrapper.

Installation

$ npm install --save @ahmerhh/WebGraphicLibrary-shader

Usage

import Shader from '@ahmerhh/WebGraphicLibrary-shader';

// setup canvas and gl

const vertexShader = new Shader(gl, gl.VERTEX_SHADER,
  `
  attribute vec3 aPos;

  void main() {
    gl_Position = vec4(aPos, 1.0);
  }
`);

API

shader = new Shader(gl, type, src)

Create a new shader, where:

  • gl is the WebGL context.
  • type is the shader type: gl.VERTEX_SHADER or gl.FRAGMENT_SHADER.
  • src is the shader source, as a string.

shader.dispose()

Delete instance. Calls gl.deleteShader.

License

MIT, see LICENSE.md for more details.

Credits

Thanks to the amazing stackgl for the inspiration.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published