on master help sign in
simplified shader type. added webgl missing throwerror
3c338bdJohn P Mayer Jr
compiler/Type/Constrain/Expression.hs+8−13
@@ -38,20 +38,15 @@ constrain env (L span expr) tipe =
38 case expr of
38 case expr of
39 Literal lit -> liftIO $ Literal.constrain env span lit tipe
39 Literal lit -> liftIO $ Literal.constrain env span lit tipe
40
40
41− GLShader _ src -> case declsRecord <$> PH.glSource src of
41+ GLShader uid src -> case PH.glSource src of
42− Nothing -> throwError [PP.text "Some sort of GLSL parse error"]
42+ Nothing -> throwError [PP.text $ "Some sort of GLSL parse error" ++ uid]
43− Just sourceTipe -> return . L span $ CEqual tipe (shaderTipe sourceTipe)
43+ Just sourceDecls -> return . L span $ CEqual tipe (shaderTipe attribute uniform varying)
44− where
44+ where
45− shaderTipe t = Env.get env Env.types "Graphics.WebGL.Shader" <| t
45+ shaderTipe a u v = Env.get env Env.types "Graphics.WebGL.Shader" <| a <| u <| v
46 glTipe = Env.get env Env.types . PH.glTipeName
46 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) ] )
47+ attribute = record (Map.map (\t -> [glTipe t]) $ PH.attribute sourceDecls) (TermN EmptyRecord1)
52− , ("uniform", [record (Map.map (\t -> [glTipe t]) $ PH.uniform extractedTipes) (TermN EmptyRecord1) ] )
48+ uniform = record (Map.map (\t -> [glTipe t]) $ PH.uniform sourceDecls) (TermN EmptyRecord1)
53− , ("varying", [record (Map.map (\t -> [glTipe t]) $ PH.varying extractedTipes) (TermN EmptyRecord1) ] )
49+ varying = record (Map.map (\t -> [glTipe t]) $ PH.varying sourceDecls) (TermN EmptyRecord1)
54− ]
55
50
56
51
57 Var name | name == saveEnvName -> return (L span CSaveEnv)
52 Var name | name == saveEnvName -> return (L span CSaveEnv)
libraries/Graphics/WebGL.elm+1−1
@@ -11,7 +11,7 @@ data GL = Dummy_GL
11data Shader auv = Dummy_Shader
11data Shader auv = Dummy_Shader
12data Program a u = Dummy_Program
12data Program a u = Dummy_Program
13
13
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
15link = Native.Graphics.WebGL.link
15link = Native.Graphics.WebGL.link
16
16
17-- Binder really should not need a program
17-- Binder really should not need a program
libraries/Native/Graphics/WebGL.js+5
@@ -168,6 +168,11 @@ Elm.Native.Graphics.WebGL.make = function(elm) {
168
168
169 function webgl(sDimensions, sfDraw) {
169 function webgl(sDimensions, sfDraw) {
170
170
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+
171 var node = newNode('canvas');
176 var node = newNode('canvas');
172 var gl = node.getContext('webgl');
177 var gl = node.getContext('webgl');
173 var sGL = Signal.constant(gl);
178 var sGL = Signal.constant(gl);