Commit 7c3157ba authored by Gaëtan Renaudeau's avatar Gaëtan Renaudeau

Migrate examples to 2.0.0

parent 21fbd017
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
}, },
"dependencies": { "dependencies": {
"gl-react-native": "file:../..", "gl-react-native": "file:../..",
"gl-react-core": "file:../../../gl-react-core",
"glsl-transitions": "^2015.11.8", "glsl-transitions": "^2015.11.8",
"react-native": "^0.14.2" "react-native": "^0.14.2"
} }
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-core");
const GL = require("gl-react-native"); const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
banner: { banner: {
frag: ` frag: `
...@@ -27,13 +27,9 @@ void main( void ) { ...@@ -27,13 +27,9 @@ void main( void ) {
class Banner extends React.Component { class Banner extends React.Component {
render () { render () {
const { width, height, time } = this.props; const { width, height, time } = this.props;
return <GL.View return <Surface width={width} height={height} opaque={false}>
shader={shaders.banner} <GL.Node shader={shaders.banner} uniforms={{ time: time }} />
width={width} </Surface>;
height={height}
uniforms={{ time: time }}
opaque={false}
/>;
} }
} }
......
...@@ -3,8 +3,8 @@ const { ...@@ -3,8 +3,8 @@ const {
View, View,
Text, Text,
} = React; } = React;
const GL = require("gl-react-core");
const GL = require("gl-react-native"); const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
drunkEffect: { drunkEffect: {
...@@ -40,38 +40,37 @@ void main() { ...@@ -40,38 +40,37 @@ void main() {
class Intro extends React.Component { class Intro extends React.Component {
render () { render () {
const { time, fps, width, height } = this.props; const { time, fps, width, height } = this.props;
return <GL.View return <Surface width={width} height={height} opaque={false}>
shader={shaders.drunkEffect} <GL.Node
width={width} shader={shaders.drunkEffect}
height={height} uniforms={{
opaque={false} time: time,
uniforms={{ freq: 20 - 14 * Math.sin(time / 7),
time: time, amp: 0.05 - 0.03 * Math.cos(time / 4),
freq: 20 - 14 * Math.sin(time / 7), colorSeparation: 0.02,
amp: 0.05 - 0.03 * Math.cos(time / 4), moving: 1
colorSeparation: 0.02, }}>
moving: 1 <GL.Uniform name="texture">
}}> <View style={{ flex: 1, justifyContent: "center" }}>
<GL.Uniform name="texture"> <Text style={{ color: "#00BDF3", fontSize: 32, letterSpacing: -1.0 }}>
<View style={{ flex: 1, justifyContent: "center" }}> GL REACT NATIVE
<Text style={{ color: "#00BDF3", fontSize: 32, letterSpacing: -1.0 }}>
GL REACT NATIVE
</Text>
<View style={{ flex: 1, flexDirection: "row", alignItems: "center", justifyContent: "center" }}>
<View style={{ backgroundColor: "#00FF66", marginRight: 8, width: 14, height: 14, borderRadius: 7, opacity: time%1 < 0.6 ? 1 : 0 }} />
<Text style={{ flex: 1, color: "#00FF66", fontSize: 14 }}>
{time.toFixed(2)}s
</Text>
<Text style={{ flex: 1, color: "#fff", fontSize: 14 }}>
{(fps).toFixed(0)} fps
</Text>
<Text style={{ flex: 1, color: "#999", fontSize: 14 }}>
{"<Text />"}
</Text> </Text>
<View style={{ flex: 1, flexDirection: "row", alignItems: "center", justifyContent: "center" }}>
<View style={{ backgroundColor: "#00FF66", marginRight: 8, width: 14, height: 14, borderRadius: 7, opacity: time%1 < 0.6 ? 1 : 0 }} />
<Text style={{ flex: 1, color: "#00FF66", fontSize: 14 }}>
{time.toFixed(2)}s
</Text>
<Text style={{ flex: 1, color: "#fff", fontSize: 14 }}>
{(fps).toFixed(0)} fps
</Text>
<Text style={{ flex: 1, color: "#999", fontSize: 14 }}>
{"<Text />"}
</Text>
</View>
</View> </View>
</View> </GL.Uniform>
</GL.Uniform> </GL.Node>
</GL.View>; </Surface>;
} }
} }
......
const React = require("react-native"); const React = require("react-native");
const { View, Text, StyleSheet } = React; const { View, Text, StyleSheet } = React;
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const {Surface} = require("gl-react-native");
const TransitionGenerator = require("./TransitionGenerator"); const TransitionGenerator = require("./TransitionGenerator");
const Transition = require("./Transition"); const Transition = require("./Transition");
...@@ -33,15 +34,15 @@ class Slideshow extends React.Component { ...@@ -33,15 +34,15 @@ class Slideshow extends React.Component {
const transitionUniforms = this._uniforms; const transitionUniforms = this._uniforms;
return <View style={styles.root}> return <View style={styles.root}>
<Transition <Surface width={width} height={height}>
width={width} <Transition
height={height} progress={transitionProgress}
progress={transitionProgress} from={transitionFrom}
from={transitionFrom} to={transitionTo}
to={transitionTo} shader={transitionShader}
shader={transitionShader} uniforms={transitionUniforms}
uniforms={transitionUniforms} />
/> </Surface>
<View style={styles.legend}> <View style={styles.legend}>
<Text style={styles.textName}>{transitionName}</Text> <Text style={styles.textName}>{transitionName}</Text>
<Text style={styles.textInfo}>(GLSL.io)</Text> <Text style={styles.textInfo}>(GLSL.io)</Text>
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height, shader, progress, from, to, uniforms }) => { ({ width, height, shader, progress, from, to, uniforms }) => {
const scale = React.PixelRatio.get(); const scale = React.PixelRatio.get();
return <GL.View return <GL.Node
preload preload
shader={shader} shader={shader}
width={width} width={width}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
imageVignette: { imageVignette: {
...@@ -55,24 +56,26 @@ class Vignette extends React.Component { ...@@ -55,24 +56,26 @@ class Vignette extends React.Component {
render () { render () {
const { width, height, time, source } = this.props; const { width, height, time, source } = this.props;
const { finger } = this.state; const { finger } = this.state;
return <GL.View return <Surface
preload
onStartShouldSetResponder={() => true}
onMoveShouldSetResponder={() => true}
onResponderMove={this.onResponderMove}
shader={shaders.imageVignette}
width={width} width={width}
height={height} height={height}
opaque={false} opaque={false}
uniforms={{ preload
time: time, onStartShouldSetResponder={() => true}
freq: 10 + 2 * Math.sin(0.7*time), onMoveShouldSetResponder={() => true}
texture: source, onResponderMove={this.onResponderMove}>
amp: 0.05 + Math.max(0, 0.03*Math.cos(time)), <GL.Node
moving: 0, shader={shaders.imageVignette}
finger: finger uniforms={{
}} time: time,
/>; freq: 10 + 2 * Math.sin(0.7*time),
texture: source,
amp: 0.05 + Math.max(0, 0.03*Math.cos(time)),
moving: 0,
finger: finger
}}
/>
</Surface>;
} }
} }
......
require("gl-react-core/react-native");
const React = require("react-native"); const React = require("react-native");
const { const {
StyleSheet, StyleSheet,
...@@ -61,6 +62,7 @@ class AdvancedEffects extends React.Component { ...@@ -61,6 +62,7 @@ class AdvancedEffects extends React.Component {
width={viewportW} width={viewportW}
height={introH} height={introH}
/> />
<Vignette <Vignette
time={time} time={time}
width={imgW} width={imgW}
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
}, },
"dependencies": { "dependencies": {
"gl-react-native": "file:../..", "gl-react-native": "file:../..",
"gl-react-core": "file:../../../gl-react-core",
"react-native": "^0.14.2", "react-native": "^0.14.2",
"react-native-material-kit": "^0.2.2" "react-native-material-kit": "^0.2.2"
} }
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
helloGL: { helloGL: {
...@@ -38,12 +39,12 @@ class HelloGL extends React.Component { ...@@ -38,12 +39,12 @@ class HelloGL extends React.Component {
render () { render () {
const { width, height } = this.props; const { width, height } = this.props;
const { value } = this.state; const { value } = this.state;
return <GL.View return <Surface width={width} height={height}>
shader={shaders.helloGL} <GL.Node
width={width} shader={shaders.helloGL}
height={height} uniforms={{ value }}
uniforms={{ value }} />
/>; </Surface>;
} }
} }
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const Blur1D = require("./Blur1D"); const Blur1D = require("./Blur1D");
module.exports = GL.createComponent(({ width, height, factor, children }) => module.exports = GL.createComponent(({ width, height, factor, children }) =>
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
blur1D: { blur1D: {
...@@ -35,7 +35,7 @@ void main () { ...@@ -35,7 +35,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height, direction, children }) => ({ width, height, direction, children }) =>
<GL.View <GL.Node
shader={shaders.blur1D} shader={shaders.blur1D}
width={width} width={width}
height={height} height={height}
...@@ -44,7 +44,7 @@ module.exports = GL.createComponent( ...@@ -44,7 +44,7 @@ module.exports = GL.createComponent(
resolution: [ width, height ] resolution: [ width, height ]
}}> }}>
<GL.Uniform name="t">{children}</GL.Uniform> <GL.Uniform name="t">{children}</GL.Uniform>
</GL.View> </GL.Node>
, { , {
displayName: "Blur1D" displayName: "Blur1D"
}); });
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
helloGL: { helloGL: {
...@@ -14,11 +14,7 @@ void main () { // This function is called FOR EACH PIXEL ...@@ -14,11 +14,7 @@ void main () { // This function is called FOR EACH PIXEL
} }
}); });
module.exports = GL.createComponent(({ width, height }) => module.exports = GL.createComponent(() =>
<GL.View <GL.Node shader={shaders.helloGL} />,
shader={shaders.helloGL}
width={width}
height={height}
/>,
{ displayName: "HelloGL" } { displayName: "HelloGL" }
); );
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
hueRotate: { hueRotate: {
...@@ -26,10 +26,10 @@ void main() { ...@@ -26,10 +26,10 @@ void main() {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ hue, children, ...rest }) => ({ hue, children, ...rest }) =>
<GL.View <GL.Node
{...rest} {...rest}
shader={shaders.hueRotate} shader={shaders.hueRotate}
uniforms={{ hue }}> uniforms={{ hue }}>
<GL.Uniform name="tex">{children}</GL.Uniform> <GL.Uniform name="tex">{children}</GL.Uniform>
</GL.View> </GL.Node>
, { displayName: "HueRotate" }); , { displayName: "HueRotate" });
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
oneFingerResponse: { oneFingerResponse: {
...@@ -55,7 +56,7 @@ class OneFingerResponse extends React.Component { ...@@ -55,7 +56,7 @@ class OneFingerResponse extends React.Component {
render () { render () {
const { width, height } = this.props; const { width, height } = this.props;
const { pressed, position } = this.state; const { pressed, position } = this.state;
return <GL.View return <Surface
onStartShouldSetResponderCapture={() => true} onStartShouldSetResponderCapture={() => true}
onMoveShouldSetResponderCapture={() => true} onMoveShouldSetResponderCapture={() => true}
onResponderTerminationRequest={() => false} onResponderTerminationRequest={() => false}
...@@ -64,10 +65,12 @@ class OneFingerResponse extends React.Component { ...@@ -64,10 +65,12 @@ class OneFingerResponse extends React.Component {
onResponderRelease={this.onTouchEnd} onResponderRelease={this.onTouchEnd}
onResponderTerminate={this.onTouchEnd} onResponderTerminate={this.onTouchEnd}
width={width} width={width}
height={height} height={height}>
shader={shaders.oneFingerResponse} <GL.Node
uniforms={{ pressed, position }} shader={shaders.oneFingerResponse}
/>; uniforms={{ pressed, position }}
/>
</Surface>;
} }
} }
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
pieProgress: { pieProgress: {
...@@ -41,11 +41,8 @@ module.exports = GL.createComponent( ...@@ -41,11 +41,8 @@ module.exports = GL.createComponent(
colorOutside, colorOutside,
radius radius
}) => }) =>
<GL.View <GL.Node
width={width}
height={height}
shader={shaders.pieProgress} shader={shaders.pieProgress}
opaque={false}
uniforms={{ uniforms={{
dim: [ width, height ], dim: [ width, height ],
progress, progress,
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
saturation: { saturation: {
...@@ -21,7 +21,7 @@ void main () { ...@@ -21,7 +21,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ factor, image, ...rest }) => ({ factor, image, ...rest }) =>
<GL.View <GL.Node
{...rest} {...rest}
shader={shaders.saturation} shader={shaders.saturation}
uniforms={{ factor, image }} uniforms={{ factor, image }}
......
require("gl-react-core/react-native");
const React = require("react-native"); const React = require("react-native");
const { const {
StyleSheet, StyleSheet,
...@@ -8,6 +10,8 @@ const { ...@@ -8,6 +10,8 @@ const {
Component, Component,
} = React; } = React;
const { Surface } = require("gl-react-native");
const { const {
mdl: { mdl: {
Progress, Progress,
...@@ -109,7 +113,9 @@ class Simple extends Component { ...@@ -109,7 +113,9 @@ class Simple extends Component {
<Demos onChange={current => this.setState({ current })} value={current}> <Demos onChange={current => this.setState({ current })} value={current}>
<Demo title="1. Hello GL"> <Demo title="1. Hello GL">
<HelloGL width={256} height={171} ref="helloGL" /> <Surface width={256} height={171} ref="helloGL">
<HelloGL />
</Surface>
<View style={{ paddingTop: 20, alignItems: "center", flexDirection: "row" }}> <View style={{ paddingTop: 20, alignItems: "center", flexDirection: "row" }}>
<Button onPress={this.onCapture1}>captureFrame()</Button> <Button onPress={this.onCapture1}>captureFrame()</Button>
{captured && <Image source={{ uri:captured }} style={{ marginLeft: 20, width: 51, height: 34 }} />} {captured && <Image source={{ uri:captured }} style={{ marginLeft: 20, width: 51, height: 34 }} />}
...@@ -117,12 +123,12 @@ class Simple extends Component { ...@@ -117,12 +123,12 @@ class Simple extends Component {
</Demo> </Demo>
<Demo title="2. Saturate an Image"> <Demo title="2. Saturate an Image">
<Saturation <Surface width={256} height={171}>
width={256} <Saturation
height={171}
factor={saturationFactor} factor={saturationFactor}
image={{ uri: "http://i.imgur.com/iPKTONG.jpg" }} image={{ uri: "http://i.imgur.com/iPKTONG.jpg" }}
/> />
</Surface>
<Slider <Slider
max={8} max={8}
onChange={saturationFactor => this.setState({ saturationFactor })} onChange={saturationFactor => this.setState({ saturationFactor })}
...@@ -130,15 +136,13 @@ class Simple extends Component { ...@@ -130,15 +136,13 @@ class Simple extends Component {
</Demo> </Demo>
<Demo id={3} current={current} title="3. Hue Rotate on Text+Image"> <Demo id={3} current={current} title="3. Hue Rotate on Text+Image">
<HueRotate <Surface autoRedraw width={256} height={180}>
autoRedraw <HueRotate hue={hue}>
width={256} <Image style={{ width: 256, height: 244 }} source={{ uri: "http://i.imgur.com/qVxHrkY.jpg" }}/>
height={180} <Text style={styles.demoText1}>Throw me to the wolves</Text>
hue={hue}> <Text style={styles.demoText2}>{text}</Text>
<Image style={{ width: 256, height: 244 }} source={{ uri: "http://i.imgur.com/qVxHrkY.jpg" }}/> </HueRotate>
<Text style={styles.demoText1}>Throw me to the wolves</Text> </Surface>
<Text style={styles.demoText2}>{text}</Text>
</HueRotate>
<Slider <Slider
max={2 * Math.PI} max={2 * Math.PI}
onChange={hue => this.setState({ hue })} onChange={hue => this.setState({ hue })}
...@@ -161,11 +165,9 @@ class Simple extends Component { ...@@ -161,11 +165,9 @@ class Simple extends Component {
}} }}
source={{ uri: "http://i.imgur.com/qM9BHCy.jpg" }}/> source={{ uri: "http://i.imgur.com/qM9BHCy.jpg" }}/>
<View style={{ position: "absolute", top: 0, left: 0 }}> <View style={{ position: "absolute", top: 0, left: 0 }}>
<PieProgress <Surface width={256} height={180} opaque={false}>
width={256} <PieProgress progress={progress} width={256} height={180} />
height={180} </Surface>
progress={progress}
/>
</View> </View>
</View> </View>
<Slider <Slider
...@@ -189,47 +191,50 @@ class Simple extends Component { ...@@ -189,47 +191,50 @@ class Simple extends Component {
</Demo> </Demo>
<Demo id={7} current={current} title="7. Blur (2-pass)"> <Demo id={7} current={current} title="7. Blur (2-pass)">
<Blur preload width={256} height={180} factor={factor + 1}> <Surface preload width={256} height={180}>
http://i.imgur.com/3On9QEu.jpg <Blur width={256} height={180} factor={factor + 1}>
</Blur> http://i.imgur.com/3On9QEu.jpg
</Blur>
</Surface>
<Slider <Slider
max={2} max={2}
onChange={factor => this.setState({ factor })} /> onChange={factor => this.setState({ factor })} />
</Demo> </Demo>
<Demo id={8} current={current} title="8. Blur+Hue over UI"> <Demo id={8} current={current} title="8. Blur+Hue over UI">
<HueRotate <Surface
hue={-switch1 + 2 * switch2 + 4 * switch3}
width={256} width={256}
height={160} height={160}
autoRedraw autoRedraw
eventsThrough eventsThrough
visibleContent> visibleContent>
<Blur <HueRotate hue={-switch1 + 2 * switch2 + 4 * switch3}>
width={256}
height={160}
factor={factor}>
<Blur <Blur
width={256} width={256}
height={160} height={160}
factor={factor/2}> factor={factor}>
<View style={{ width: 256, height: 160, padding: 10, backgroundColor: "#F9F9F9" }}> <Blur
<Slider width={256}
style={{ height: 80 }} height={160}
max={2} factor={factor/2}>
onChange={factor => this.setState({ factor })} <View style={{ width: 256, height: 160, padding: 10, backgroundColor: "#F9F9F9" }}>
/> <Slider
<View style={{ height: 60, flexDirection: "row", alignItems: "center" }}> style={{ height: 80 }}
<Switch style={{flex:1}} checked={switch1} onCheckedChange={({checked:switch1}) => this.setState({ switch1 })} /> max={2}
<Switch style={{flex:1}} checked={switch2} onCheckedChange={({checked:switch2}) => this.setState({ switch2 })} /> onChange={factor => this.setState({ factor })}
<Switch style={{flex:1}} checked={switch3} onCheckedChange={({checked:switch3}) => this.setState({ switch3 })} /> />
</View> <View style={{ height: 60, flexDirection: "row", alignItems: "center" }}>
<Progress progress={factor} style={{height: 10, marginTop: 8, flex:1}} /> <Switch style={{flex:1}} checked={switch1} onCheckedChange={({checked:switch1}) => this.setState({ switch1 })} />
<Switch style={{flex:1}} checked={switch2} onCheckedChange={({checked:switch2}) => this.setState({ switch2 })} />
<Switch style={{flex:1}} checked={switch3} onCheckedChange={({checked:switch3}) => this.setState({ switch3 })} />
</View>
<Progress progress={factor} style={{height: 10, marginTop: 8, flex:1}} />
</View> </View>
</Blur>
</Blur> </Blur>
</Blur> </HueRotate>
</HueRotate> </Surface>
</Demo> </Demo>
<Demo id={9} current={current} title="9. Texture from array"> <Demo id={9} current={current} title="9. Texture from array">
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
}, },
"dependencies": { "dependencies": {
"gl-react-native": "file:../..", "gl-react-native": "file:../..",
"react-native": "^0.15.0" "gl-react-core": "file:../../../gl-react-core",
"react-native": "^0.14.2"
}, },
"devDependencies": { "devDependencies": {
"react-native-cli": "^0.1.7" "react-native-cli": "^0.1.7"
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
add: { add: {
...@@ -23,7 +23,7 @@ module.exports = GL.createComponent( ...@@ -23,7 +23,7 @@ module.exports = GL.createComponent(
({ width, height, children }) => { ({ width, height, children }) => {
if (!children || children.length !== 2) throw new Error("You must provide 2 children to Add"); if (!children || children.length !== 2) throw new Error("You must provide 2 children to Add");
const [t1, t2] = children; const [t1, t2] = children;
return <GL.View return <GL.Node
shader={shaders.add} shader={shaders.add}
width={width} width={width}
height={height} height={height}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const { const {
PropTypes PropTypes
} = React; } = React;
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const { const {
PropTypes PropTypes
...@@ -34,7 +34,7 @@ void main () { ...@@ -34,7 +34,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height, direction, children }) => ({ width, height, direction, children }) =>
<GL.View <GL.Node
shader={shaders.blur1D} shader={shaders.blur1D}
width={width} width={width}
height={height} height={height}
...@@ -43,7 +43,7 @@ module.exports = GL.createComponent( ...@@ -43,7 +43,7 @@ module.exports = GL.createComponent(
resolution: [ width, height ] resolution: [ width, height ]
}}> }}>
<GL.Uniform name="t">{children}</GL.Uniform> <GL.Uniform name="t">{children}</GL.Uniform>
</GL.View> </GL.Node>
, { , {
displayName: "Blur1D" displayName: "Blur1D"
}); });
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
Copy: { Copy: {
...@@ -23,7 +23,7 @@ void main () { ...@@ -23,7 +23,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height, children: t, last, ...rest }) => ({ width, height, children: t, last, ...rest }) =>
<GL.View <GL.Node
{...rest} {...rest}
shader={shaders.Copy} shader={shaders.Copy}
width={width} width={width}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
display2: { display2: {
...@@ -27,7 +27,7 @@ module.exports = GL.createComponent( ...@@ -27,7 +27,7 @@ module.exports = GL.createComponent(
if (!children || children.length !== 2) throw new Error("You must provide 2 children to Display2"); if (!children || children.length !== 2) throw new Error("You must provide 2 children to Display2");
let [t1, t2] = children; let [t1, t2] = children;
if (vertical) [t1,t2]=[t2,t1]; // just because webgl y's is reversed if (vertical) [t1,t2]=[t2,t1]; // just because webgl y's is reversed
return <GL.View return <GL.Node
{...rest} {...rest}
shader={shaders.display2} shader={shaders.display2}
width={width} width={width}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
helloGL: { helloGL: {
...@@ -16,7 +16,7 @@ void main () { // This function is called FOR EACH PIXEL ...@@ -16,7 +16,7 @@ void main () { // This function is called FOR EACH PIXEL
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height }) => ({ width, height }) =>
<GL.View <GL.Node
shader={shaders.helloGL} shader={shaders.helloGL}
width={width} width={width}
height={height} height={height}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
layer: { layer: {
...@@ -23,7 +23,7 @@ module.exports = GL.createComponent( ...@@ -23,7 +23,7 @@ module.exports = GL.createComponent(
({ children, ...rest }) => { ({ children, ...rest }) => {
if (!children || children.length !== 2) throw new Error("You must provide 2 children to Layer"); if (!children || children.length !== 2) throw new Error("You must provide 2 children to Layer");
const [t1, t2] = children; const [t1, t2] = children;
return <GL.View return <GL.Node
{...rest} {...rest}
shader={shaders.layer} shader={shaders.layer}
uniforms={{ t1, t2 }} uniforms={{ t1, t2 }}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
multiply: { multiply: {
...@@ -23,7 +23,7 @@ module.exports = GL.createComponent( ...@@ -23,7 +23,7 @@ module.exports = GL.createComponent(
({ width, height, children }) => { ({ width, height, children }) => {
if (!children || children.length !== 2) throw new Error("You must provide 2 children to Multiply"); if (!children || children.length !== 2) throw new Error("You must provide 2 children to Multiply");
const [t1, t2] = children; const [t1, t2] = children;
return <GL.View return <GL.Node
shader={shaders.multiply} shader={shaders.multiply}
width={width} width={width}
height={height} height={height}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
TransparentNonPremultiplied: { TransparentNonPremultiplied: {
...@@ -18,7 +18,7 @@ void main () { ...@@ -18,7 +18,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ children: t, ...rest }) => ({ children: t, ...rest }) =>
<GL.View <GL.Node
{...rest} {...rest}
opaque={false} opaque={false}
shader={shaders.TransparentNonPremultiplied} shader={shaders.TransparentNonPremultiplied}
......
require("gl-react-core/react-native");
const React = require("react-native"); const React = require("react-native");
const { const {
AppRegistry,
Text, Text,
View, View,
ScrollView, ScrollView,
Image, Image,
} = React; } = React;
const { Surface } = require("gl-react-native");
const Blur = require("./Blur"); const Blur = require("./Blur");
const Add = require("./Add"); const Add = require("./Add");
const Multiply = require("./Multiply"); const Multiply = require("./Multiply");
...@@ -54,7 +54,7 @@ class Tests extends React.Component { ...@@ -54,7 +54,7 @@ class Tests extends React.Component {
</Text>)} </Text>)}
</View>; </View>;
const img = "http://i.imgur.com/zJIxPEo.jpg?t="+Date.now(); const img = "http://i.imgur.com/zJIxPEo.jpg";
const blurredImage = const blurredImage =
<Blur factor={4} passes={6} width={200} height={200}> <Blur factor={4} passes={6} width={200} height={200}>
...@@ -68,22 +68,23 @@ class Tests extends React.Component { ...@@ -68,22 +68,23 @@ class Tests extends React.Component {
</Layer>; </Layer>;
return <ScrollView style={{ backgroundColor: "#000" }}> return <ScrollView style={{ backgroundColor: "#000" }}>
<Display2 width={viewportW} height={viewportW} preload onLoad={this.onLoad} onProgress={this.onProgress}> <Surface width={viewportW} height={viewportW} preload onLoad={this.onLoad} onProgress={this.onProgress}>
<Add width={viewportW/2} height={viewportH/2}> <Display2>
{txt} <Add width={viewportW/2} height={viewportH/2}>
{helloGL} {txt}
</Add> {helloGL}
<Display2 width={viewportW/2} height={viewportH/2} vertical> </Add>
<Blur factor={1} passes={4} width={viewportW/2} height={viewportH/4}> <Display2 width={viewportW/2} height={viewportH/2} vertical>
<Multiply> <Blur factor={1} passes={4} width={viewportW/2} height={viewportH/4}>
{blurredImageOverText} <Multiply>
{helloGL} {blurredImageOverText}
</Multiply> {helloGL}
</Blur> </Multiply>
{blurredImage} </Blur>
{blurredImage}
</Display2>
</Display2> </Display2>
</Display2> </Surface>
<View style={{ flexDirection: "row", flexWrap: "wrap" }}> <View style={{ flexDirection: "row", flexWrap: "wrap" }}>
...@@ -94,47 +95,40 @@ class Tests extends React.Component { ...@@ -94,47 +95,40 @@ class Tests extends React.Component {
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false} last> <Surface width={debugSize} height={debugSize} opaque={false}>
http://i.imgur.com/mp79p5T.png <Copy last>
</Copy>
</NativeLayer>
<NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false} last>
<Copy>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
</Copy> </Copy>
</Copy> </Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false} last> <Surface width={debugSize} height={debugSize} opaque={false}>
<Copy> <Copy last>
<Copy> <Copy>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
</Copy> </Copy>
</Copy> </Copy>
</Copy> </Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false} last> <Surface width={debugSize} height={debugSize} opaque={false}>
<Copy> <Copy last>
<Copy> <Copy>
<Copy> <Copy>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
</Copy> </Copy>
</Copy> </Copy>
</Copy> </Copy>
</Copy> </Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false}> <Surface width={debugSize} height={debugSize} opaque={false}>
<Copy last> <Copy last>
<Copy> <Copy>
<Copy> <Copy>
...@@ -144,28 +138,35 @@ class Tests extends React.Component { ...@@ -144,28 +138,35 @@ class Tests extends React.Component {
</Copy> </Copy>
</Copy> </Copy>
</Copy> </Copy>
</Copy> </Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<NativeLayer> <Surface width={debugSize} height={debugSize} opaque={false}>
<Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} /> <Copy last>
<TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha> <Copy>
<HelloGL /> <Copy>
</TransparentNonPremultiplied> <Copy>
</NativeLayer> <Copy>
http://i.imgur.com/mp79p5T.png
</Copy>
</Copy>
</Copy>
</Copy>
</Copy>
</Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<NativeLayer> <NativeLayer>
<Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
<TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha> <Surface width={debugSize} height={debugSize}>
<TransparentNonPremultiplied> <TransparentNonPremultiplied>
<HelloGL /> <HelloGL />
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</TransparentNonPremultiplied> </Surface>
</NativeLayer> </NativeLayer>
</NativeLayer> </NativeLayer>
...@@ -173,42 +174,62 @@ class Tests extends React.Component { ...@@ -173,42 +174,62 @@ class Tests extends React.Component {
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<NativeLayer> <NativeLayer>
<Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
<TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha> <Surface width={debugSize} height={debugSize}>
<Copy> <TransparentNonPremultiplied>
<TransparentNonPremultiplied> <TransparentNonPremultiplied>
<Copy> <HelloGL />
http://i.imgur.com/S22HNaU.png
</Copy>
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</Copy> </TransparentNonPremultiplied>
</TransparentNonPremultiplied> </Surface>
</NativeLayer> </NativeLayer>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Layer width={debugSize} height={debugSize} opaque={false} premultipliedAlpha debug> <NativeLayer>
http://i.imgur.com/mp79p5T.png <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
<TransparentNonPremultiplied> <Surface width={debugSize} height={debugSize}>
<HelloGL /> <TransparentNonPremultiplied>
</TransparentNonPremultiplied> <Copy>
</Layer> <TransparentNonPremultiplied>
<Copy>
http://i.imgur.com/S22HNaU.png
</Copy>
</TransparentNonPremultiplied>
</Copy>
</TransparentNonPremultiplied>
</Surface>
</NativeLayer>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Layer width={debugSize} height={debugSize} opaque={false}> <Surface width={debugSize} height={debugSize} opaque={false}>
http://i.imgur.com/mp79p5T.png <Layer>
<TransparentNonPremultiplied> http://i.imgur.com/mp79p5T.png
<Copy> <TransparentNonPremultiplied>
<TransparentNonPremultiplied> <HelloGL />
<Copy> </TransparentNonPremultiplied>
http://i.imgur.com/S22HNaU.png </Layer>
</Copy> </Surface>
</TransparentNonPremultiplied> </NativeLayer>
</Copy>
</TransparentNonPremultiplied> <NativeLayer width={debugSize} height={debugSize}>
</Layer> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Surface width={debugSize} height={debugSize} opaque={false}>
<Layer>
http://i.imgur.com/mp79p5T.png
<TransparentNonPremultiplied>
<Copy>
<TransparentNonPremultiplied>
<Copy>
http://i.imgur.com/S22HNaU.png
</Copy>
</TransparentNonPremultiplied>
</Copy>
</TransparentNonPremultiplied>
</Layer>
</Surface>
</NativeLayer> </NativeLayer>
</View> </View>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment