/gl-context

Get WebGL context.

Primary LanguageJavaScriptMIT LicenseMIT

GL Context

Get the WebGL context from a canvas.

Installation

$ npm install --save @vaalentin/gl-context

Usage

import getGl from '@vaalentin/gl-context';

const canvas = document.createElement('canvas');
const gl = getGl(canvas);

if(gl == null) {
  // WebGL is not supported
}

API

gl = getGl(canvas)

Returns the WebGL context from the canvas. If it fails, gl is null.

License

MIT, see LICENSE.md for more details.

Credits

Thanks to the amazing stackgl for the inspiration.