fwgl-javascript 0.1.0.4 → 0.1.0.5
raw patch · 3 files changed
+31/−2 lines, 3 filesdep ~fwgl
Dependency ranges changed: fwgl
Files
- FWGL/Backend/JavaScript.hs +26/−0
- FWGL/Backend/JavaScript/WebGL/Types.hs +3/−0
- fwgl-javascript.cabal +2/−2
FWGL/Backend/JavaScript.hs view
@@ -26,6 +26,24 @@ \img.onload = function() { return $2(img); }; " loadImageRaw :: JSString -> JSFun (JSRef a -> IO ()) -> IO () +foreign import javascript unsafe+ "var xhr = new XMLHttpRequest; \+ \xhr.open(\"GET\", $1, true); \+ \xhr.onreadystatechange = function () { \+ \ if (xhr.readyState == 4) { \+ \ if (xhr.status == 200) { \+ \ $2(xhr.responseText); \+ \ } else { \+ \ $3(xhr.responseText); \+ \ } \+ \ } \+ \}; \+ \xhr.send(); "+ loadTextFileRaw :: JSString+ -> JSFun (JSString -> IO ())+ -> JSFun (JSString -> IO ())+ -> IO ()+ foreign import javascript unsafe "document.querySelector($1)" query :: JSString -> IO (JSRef a) @@ -47,6 +65,14 @@ do (Just w) <- getProp "width" img >>= fromJSRef (Just h) <- getProp "height" img >>= fromJSRef f (img, w, h)++ loadTextFile url f =+ do fRight <- asyncCallback1 NeverRetain $+ f . Right . fromJSString+ fLeft <- asyncCallback1 NeverRetain $+ f . Left . fromJSString+ forkIO $ loadTextFileRaw (toJSString url) fRight fLeft+ return () setup initState draw customInp sigf = do element <- query $ toJSString "canvas"
FWGL/Backend/JavaScript/WebGL/Types.hs view
@@ -74,6 +74,9 @@ data Texture_ type Texture = JSRef Texture_ +instance Eq Texture where+ (==) = eqRef+ data UniformLocation_ type UniformLocation = JSRef UniformLocation_
fwgl-javascript.cabal view
@@ -1,5 +1,5 @@ name: fwgl-javascript-version: 0.1.0.4+version: 0.1.0.5 synopsis: FWGL GHCJS backend description: FWGL GHCJS backend homepage: https://github.com/ziocroc/FWGL@@ -16,6 +16,6 @@ exposed-modules: FWGL.Backend.JavaScript other-modules: FWGL.Backend.JavaScript.WebGL, FWGL.Backend.JavaScript.Event, FWGL.Backend.JavaScript.WebGL.Const, FWGL.Backend.JavaScript.WebGL.Types, FWGL.Backend.JavaScript.WebGL.Raw other-extensions: FlexibleInstances, MultiParamTypeClasses, TypeSynonymInstances- build-depends: fwgl >= 0.1 && < 0.2, Yampa, base >=4.7 && <4.9, hashable >=1.2 && <1.3, unordered-containers >=0.2 && <0.3, ghcjs-base+ build-depends: fwgl > 0.1.2.0 && < 0.2, Yampa, base >=4.7 && <4.9, hashable >=1.2 && <1.3, unordered-containers >=0.2 && <0.3, ghcjs-base hs-source-dirs: . default-language: Haskell2010