README.md 1.84 KB
Newer Older
1 2
# gl-react-native

Earle Castledine's avatar
Earle Castledine committed
3
OpenGL bindings for react-native to implement complex effects over images and components, in the descriptive VDOM paradigm.
4

Earle Castledine's avatar
Earle Castledine committed
5
More technically, `gl-react-native` allows you to write a [fragment shader](https://www.opengl.org/wiki/Fragment_Shader) that covers a View. The shader can render: generated graphics/demos, effects on top of images, effects over any UI content... anything you can imagine!
6

7
**`gl-react-native` is directly inspired from [`gl-react`](http://github.com/ProjectSeptemberInc/gl-react) and implement the same API (so you can write "universal" code).**
8

Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
9
[![](https://github.com/ProjectSeptemberInc/gl-react-native/raw/master/imgs/simple.gif)](./Examples/Simple)[![](https://github.com/ProjectSeptemberInc/gl-react-native/raw/master/imgs/advancedeffects.gif)](./Examples/AdvancedEffects)
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
10

Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
### HelloGL Gist

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

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);
}`
  }
});

28
class HelloGL extends GL.Component {
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
29 30 31 32 33 34 35 36 37 38 39
  render () {
    const { width, height } = this.props;
    return <GL.View
      shader={shaders.helloGL}
      width={width}
      height={height}
    />;
  }
}
```

40
![](imgs/hellogl.jpg)
41

Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
42 43
## Installation

44
a few steps are required to install `gl-react-native`:
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
45

Gaëtan Renaudeau's avatar
typo  
Gaëtan Renaudeau committed
46
**Install the dependency to your React Native application:**
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
47 48 49 50 51

```
npm i --save gl-react-native
```

52
**Configure your React Native Application:**
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
53

54
![](imgs/install-steps.png)
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
55 56


57
## Influence / Credits
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
58 59 60 61

- [stack.gl](http://stack.gl/) approach
- [GLSL.io](http://glsl.io/) and [Diaporama](https://github.com/gre/diaporama)
- Source code of [React Native](https://github.com/facebook/react-native)
62 63

## Documentation
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
64

65
[**Gitbook**](http://projectseptemberinc.gitbooks.io/gl-react/content/)