mirror of
https://github.com/gre/gl-react.git
synced 2026-01-18 16:16:59 +00:00
25 lines
621 B
JavaScript
25 lines
621 B
JavaScript
const React = require("react");
|
|
const GL = require("gl-react");
|
|
|
|
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%.
|
|
}
|
|
`
|
|
}
|
|
});
|
|
|
|
module.exports = GL.createComponent(({ width, height }) =>
|
|
<GL.View
|
|
shader={shaders.helloGL}
|
|
width={width}
|
|
height={height}
|
|
/>,
|
|
{ displayName: "HelloGL" }
|
|
);
|