Last active
December 17, 2016 06:31
-
-
Save soma-arc/9cd053145adf0e56f4b69666dcf94862 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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