README.md 2.43 KB
Newer Older
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
1
**[Gitbook documentation](http://projectseptemberinc.gitbooks.io/gl-react/content/) / [Github](https://github.com/ProjectSeptemberInc/gl-react-native/) / [gl-react](https://github.com/ProjectSeptemberInc/gl-react/)** / [#gl-react on reactiflux](https://discordapp.com/channels/102860784329052160/106102146109325312)
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
2

Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
3
# <img width="32" alt="icon" src="https://cloud.githubusercontent.com/assets/211411/9813786/eacfcc24-5888-11e5-8f9b-5a907a2cbb21.png"> gl-react-native
4

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

Earle Castledine's avatar
Earle Castledine committed
7
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!
8

Earle Castledine's avatar
Earle Castledine committed
9
**`gl-react-native` is directly inspired from our other project, [`gl-react`](http://github.com/ProjectSeptemberInc/gl-react) and implements the same API (so you can write "universal" code).**
10

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

Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
### 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);
}`
  }
});

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

42
![](https://github.com/ProjectSeptemberInc/gl-react-native/raw/master/docs/hellogl.jpg)
43

Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
44 45
## Installation

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

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

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

54
**Configure your React Native Application:**
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
55

56
![](https://github.com/ProjectSeptemberInc/gl-react-native/raw/master/docs/install-steps.png)
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
57 58


59
## Influence / Credits
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
60 61 62 63

- [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)
64 65

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

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