on master help sign in
simplified shader type. added webgl missing throwerror
commit3c338bdd1f1a266a3df8bfc435ad006a8278fd33 authorJohn P Mayer Jr <john.p.mayer.jr@gmail.com> dateTue 10 Dec 2013, 13:09 (13 years ago) parente2fc4da
3 files changed+14−14
compiler/Type/Constrain/Expression.hs+8−13 libraries/Graphics/WebGL.elm+1−1 libraries/Native/Graphics/WebGL.js+5
compiler/Type/Constrain/Expression.hs+8−13
@@ -38,20 +38,15 @@ constrain env (L span expr) tipe =
3838 case expr of
3939 Literal lit -> liftIO $ Literal.constrain env span lit tipe
4040
41− GLShader _ src -> case declsRecord <$> PH.glSource src of
42− Nothing -> throwError [PP.text "Some sort of GLSL parse error"]
43− Just sourceTipe -> return . L span $ CEqual tipe (shaderTipe sourceTipe)
44− where
45− shaderTipe t = Env.get env Env.types "Graphics.WebGL.Shader" <| t
41+ GLShader uid src -> case PH.glSource src of
42+ Nothing -> throwError [PP.text $ "Some sort of GLSL parse error" ++ uid]
43+ Just sourceDecls -> return . L span $ CEqual tipe (shaderTipe attribute uniform varying)
44+ where
45+ shaderTipe a u v = Env.get env Env.types "Graphics.WebGL.Shader" <| a <| u <| v
4646 glTipe = Env.get env Env.types . PH.glTipeName
47− declsRecord :: PH.GLShaderDecls -> TermN Variable
48− declsRecord extractedTipes = record (fields' extractedTipes) (TermN EmptyRecord1)
49− fields' :: PH.GLShaderDecls -> Map.Map String [Type]
50− fields' extractedTipes = Map.fromList
51− [ ("attribute", [record (Map.map (\t -> [glTipe t]) $ PH.attribute extractedTipes) (TermN EmptyRecord1) ] )
52− , ("uniform", [record (Map.map (\t -> [glTipe t]) $ PH.uniform extractedTipes) (TermN EmptyRecord1) ] )
53− , ("varying", [record (Map.map (\t -> [glTipe t]) $ PH.varying extractedTipes) (TermN EmptyRecord1) ] )
54− ]
47+ attribute = record (Map.map (\t -> [glTipe t]) $ PH.attribute sourceDecls) (TermN EmptyRecord1)
48+ uniform = record (Map.map (\t -> [glTipe t]) $ PH.uniform sourceDecls) (TermN EmptyRecord1)
49+ varying = record (Map.map (\t -> [glTipe t]) $ PH.varying sourceDecls) (TermN EmptyRecord1)
5550
5651
5752 Var name | name == saveEnvName -> return (L span CSaveEnv)
libraries/Graphics/WebGL.elm+1−1
@@ -11,7 +11,7 @@ data GL = Dummy_GL
1111data Shader auv = Dummy_Shader
1212data Program a u = Dummy_Program
1313
14−link : GL -> Shader { attribute : a, uniform : u, varying : v } -> Shader { attribute : {}, uniform : {}, varying : v } -> Program a u
14+link : GL -> Shader a u v -> Shader {} {} v -> Program a u
1515link = Native.Graphics.WebGL.link
1616
1717-- Binder really should not need a program
libraries/Native/Graphics/WebGL.js+5
@@ -168,6 +168,11 @@ Elm.Native.Graphics.WebGL.make = function(elm) {
168168
169169 function webgl(sDimensions, sfDraw) {
170170
171+ if (!window.WebGLRenderingContext) {
172+ throw new Error("It appears your browser does not support WebGL! http://get.webgl.org/troubleshooting");
173+ return;
174+ }
175+
171176 var node = newNode('canvas');
172177 var gl = node.getContext('webgl');
173178 var sGL = Signal.constant(gl);