Gaëtan Renaudeau bb08ec3688 improve README
2015-08-21 17:10:55 +02:00
2015-08-21 17:10:55 +02:00
2015-08-20 23:35:34 +02:00
2015-08-20 23:35:34 +02:00
2015-08-20 23:44:14 +02:00
2015-08-19 20:25:49 +02:00
2015-08-20 20:51:24 +02:00
2015-08-21 17:10:55 +02:00

gl-react

WebGL bindings for react to implement complex graphics and image effects, in VDOM descriptive paradigm.

See also: gl-react-native.

Examples

Open Examples page and read the code.

HelloGL Gist

const React = require("react");
const GL = require("gl-react");

const shaders = GL.Shaders.create({
  helloGL: {
    frag: `
precision highp float;
varying vec2 uv;
void main () {
  gl_FragColor = vec4(uv.x, uv.y, 0.5, 1.0);
}`
  }
});

class HelloGL extends React.Component {
  render () {
    const { width, height } = this.props;
    return <GL.View
      shader={shaders.helloGL}
      width={width}
      height={height}
    />;
  }
}

Installation

npm i --save gl-react

Docs and difference with gl-react-native

gl-react adopts the same API of gl-react-native, therefore you can read gl-react-native documentation.

However, here are the few differences:

Texture format

Instead of adopting React Native {uri: "http://..."} format, you can simply set a "http:..." as a texture uniform, the {uri} format is still supported for compatibility purpose.

GL.Target support

GL.Target have a more limited support because the web does not allow to draw DOM element in Canvas.

Only one child is supported per GL.Target and it MUST be either: an <img />, a <video /> or a <canvas />.

You might want to take a look at react-canvas for drawing content.

Description
gl-react – React library to write and compose WebGL shaders
Readme MIT 135 MiB
Languages
JavaScript 96.3%
CSS 2.4%
GLSL 0.8%
Shell 0.3%
HTML 0.2%