HelloGL.js 636 Bytes
Newer Older
1
const React = require("react-native");
2
const GL = require("gl-react-core");
3 4 5 6 7 8 9 10 11 12 13 14 15 16

const shaders = GL.Shaders.create({
  helloGL: {
    frag: `
precision highp float;
varying vec2 uv; // This variable vary in all pixel position (normalized from vec2(0.0,0.0) to vec2(1.0,1.0))

void main () { // This function is called FOR EACH PIXEL
  gl_FragColor = vec4(uv.x, uv.y, 0.5, 1.0); // red vary over X, green vary over Y, blue is 50%, alpha is 100%.
}
    `
  }
});

17 18
module.exports = GL.createComponent(
  ({ width, height }) =>
19
  <GL.Node
20 21 22 23 24 25
    shader={shaders.helloGL}
    width={width}
    height={height}
  />,
  { displayName: "HelloGL" }
);