Skip to content

Instantly share code, notes, and snippets.

@soma-arc
Last active December 17, 2016 06:31
Show Gist options
  • Save soma-arc/9cd053145adf0e56f4b69666dcf94862 to your computer and use it in GitHub Desktop.
Save soma-arc/9cd053145adf0e56f4b69666dcf94862 to your computer and use it in GitHub Desktop.
(enable-console-print!)
(defonce gl (aget js/window "deps" "gl"))
(defonce shaders (.-Shaders gl))
(defonce surface (.-Surface (aget js/window "deps" "surface")))
(defonce hello-shader
(.create shaders
(clj->js {:hello {:frag "precision highp float;
varying vec2 uv;
uniform float blue;
void main () {
gl_FragColor = vec4(uv.x, uv.y, blue, 1.0);
}"}})))
(defn hello-gl [blue]
(let [node (.-Node gl)
sh (aget hello-shader "hello")]
[:> node {:uniforms blue
:shader sh}]))
(defn gl-canvas []
[:> surface {:width 300 :height 200}
[hello-gl {:blue 0.5}]])
(defn mount-root []
(reagent/render [gl-canvas] (.getElementById js/document "app")))
(defn init! []
(mount-root))
window.deps = {
'react' : require('react'),
'react-dom' : require('react-dom'),
'gl': require('gl-react'),
'surface': require('gl-react-dom'),
};
window.React = window.deps['react'];
window.ReactDOM = window.deps['react-dom'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment