summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-22 11:20:30 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-22 11:23:19 +0100
commit5e184db3c1319caebdcd8fbab25596cd7f82a480 (patch)
tree69ec2802efd596009ca99eb004f8e4271bf8e98c
parentaa362273e73353aae70eda996ee69e266d9b004a (diff)
rename zeroComp --> zero; oneComp --> one
-rw-r--r--lc/Builtins.lc44
-rw-r--r--testdata/Graphics.lc24
-rw-r--r--testdata/performance/Graphics.out2
-rw-r--r--testdata/reject.ignore/adhoc.reject.lc2
4 files changed, 34 insertions, 38 deletions
diff --git a/lc/Builtins.lc b/lc/Builtins.lc
index 41cbbeb0..23035684 100644
--- a/lc/Builtins.lc
+++ b/lc/Builtins.lc
@@ -101,39 +101,39 @@ instance Signed Int
101instance Signed Float 101instance Signed Float
102 102
103class Component a where 103class Component a where
104 zeroComp :: a 104 zero :: a
105 oneComp :: a 105 one :: a
106 106
107instance Component Int where 107instance Component Int where
108 zeroComp = 0 :: Int 108 zero = 0 :: Int
109 oneComp = 1 :: Int 109 one = 1 :: Int
110instance Component Word where 110instance Component Word where
111 zeroComp = 0 :: Word 111 zero = 0 :: Word
112 oneComp = 1 :: Word 112 one = 1 :: Word
113instance Component Float where 113instance Component Float where
114 zeroComp = 0.0 114 zero = 0.0
115 oneComp = 1.0 115 one = 1.0
116instance Component (VecS Float 2) where 116instance Component (VecS Float 2) where
117 zeroComp = V2 0.0 0.0 117 zero = V2 0.0 0.0
118 oneComp = V2 1.0 1.0 118 one = V2 1.0 1.0
119instance Component (VecS Float 3) where 119instance Component (VecS Float 3) where
120 zeroComp = V3 0.0 0.0 0.0 120 zero = V3 0.0 0.0 0.0
121 oneComp = V3 1.0 1.0 1.0 121 one = V3 1.0 1.0 1.0
122instance Component (VecS Float 4) where 122instance Component (VecS Float 4) where
123 zeroComp = V4 0.0 0.0 0.0 0.0 123 zero = V4 0.0 0.0 0.0 0.0
124 oneComp = V4 1.0 1.0 1.0 1.0 124 one = V4 1.0 1.0 1.0 1.0
125instance Component Bool where 125instance Component Bool where
126 zeroComp = False 126 zero = False
127 oneComp = True 127 one = True
128instance Component (VecS Bool 2) where 128instance Component (VecS Bool 2) where
129 zeroComp = V2 False False 129 zero = V2 False False
130 oneComp = V2 True True 130 one = V2 True True
131instance Component (VecS Bool 3) where 131instance Component (VecS Bool 3) where
132 zeroComp = V3 False False False 132 zero = V3 False False False
133 oneComp = V3 True True True 133 one = V3 True True True
134instance Component (VecS Bool 4) where 134instance Component (VecS Bool 4) where
135 zeroComp = V4 False False False False 135 zero = V4 False False False False
136 oneComp = V4 True True True True 136 one = V4 True True True True
137 137
138class Integral a 138class Integral a
139 139
diff --git a/testdata/Graphics.lc b/testdata/Graphics.lc
index 29c110da..666438c1 100644
--- a/testdata/Graphics.lc
+++ b/testdata/Graphics.lc
@@ -3,8 +3,6 @@ module Graphics where
3import Material hiding (Blending) 3import Material hiding (Blending)
4import SampleMaterial 4import SampleMaterial
5 5
6zero' = zeroComp
7one' = oneComp
8--texture' _ _ = V4 0.0 0.0 0.0 0.0 --PrimTexture 6--texture' _ _ = V4 0.0 0.0 0.0 0.0 --PrimTexture
9texture' = texture2D 7texture' = texture2D
10 8
@@ -40,7 +38,7 @@ mkRasterContext ca = TriangleCtx cull PolygonFill offset LastVertex
40 CT_TwoSided -> CullNone 38 CT_TwoSided -> CullNone
41 39
42mkaccumulationContext :: StageAttrs -> (FragmentOperation (Depth Float), FragmentOperation (Color (Vec 4 Float))) 40mkaccumulationContext :: StageAttrs -> (FragmentOperation (Depth Float), FragmentOperation (Color (Vec 4 Float)))
43mkaccumulationContext sa = (DepthOp depthFunc depthWrite, ColorOp blend (one' :: Vec 4 Bool)) 41mkaccumulationContext sa = (DepthOp depthFunc depthWrite, ColorOp blend (one :: Vec 4 Bool))
44 where 42 where
45 depthWrite = saDepthWrite sa 43 depthWrite = saDepthWrite sa
46 depthFunc = case saDepthFunc sa of 44 depthFunc = case saDepthFunc sa of
@@ -60,7 +58,7 @@ mkaccumulationContext sa = (DepthOp depthFunc depthWrite, ColorOp blend (one' ::
60 B_Zero -> Zero' 58 B_Zero -> Zero'
61 blend = case saBlend sa of 59 blend = case saBlend sa of
62 Nothing -> NoBlending 60 Nothing -> NoBlending
63 Just (src,dst) -> Blend (FuncAdd,FuncAdd) ((srcF,dstF),(srcF,dstF)) one' 61 Just (src,dst) -> Blend (FuncAdd,FuncAdd) ((srcF,dstF),(srcF,dstF)) one
64 where 62 where
65 srcF = cvt src 63 srcF = cvt src
66 dstF = cvt dst 64 dstF = cvt dst
@@ -101,10 +99,10 @@ mkColor ca sa = \rgbaV ->
101 rgb' = case saRGBGen sa of 99 rgb' = case saRGBGen sa of
102 RGB_Wave w -> let c = mkWave w in V3 c c c :: Vec 3 Float 100 RGB_Wave w -> let c = mkWave w in V3 c c c :: Vec 3 Float
103 RGB_Const r g b -> V3 r g b 101 RGB_Const r g b -> V3 r g b
104 RGB_Identity -> one' 102 RGB_Identity -> one
105 RGB_IdentityLighting -> V3 identityLight' identityLight' identityLight' 103 RGB_IdentityLighting -> V3 identityLight' identityLight' identityLight'
106 RGB_Entity -> entityRGB 104 RGB_Entity -> entityRGB
107 RGB_OneMinusEntity -> one' - entityRGB 105 RGB_OneMinusEntity -> one - entityRGB
108 RGB_ExactVertex -> V3 rV gV bV 106 RGB_ExactVertex -> V3 rV gV bV
109 RGB_Vertex -> (V3 rV gV bV) *! identityLight' 107 RGB_Vertex -> (V3 rV gV bV) *! identityLight'
110 RGB_LightingDiffuse -> white' -- TODO 108 RGB_LightingDiffuse -> white' -- TODO
@@ -115,7 +113,7 @@ mkColor ca sa = \rgbaV ->
115 model: position 113 model: position
116 normal 114 normal
117 -} 115 -}
118 RGB_OneMinusVertex -> one' - ((V3 rV gV bV) *! identityLight') 116 RGB_OneMinusVertex -> one - ((V3 rV gV bV) *! identityLight')
119 117
120 alpha = case saAlphaGen sa of 118 alpha = case saAlphaGen sa of
121 A_Wave w -> let a = mkWave w in clamp a 0 1 119 A_Wave w -> let a = mkWave w in clamp a 0 1
@@ -301,8 +299,8 @@ errorShaderFill fb = accumulate fragCtx frag rast fb
301 v4 = viewProj *. (worldMat *. snoc p 1) 299 v4 = viewProj *. (worldMat *. snoc p 1)
302 c' = V4 c%r c%g c%b 0.5 300 c' = V4 c%r c%g c%b 0.5
303 301
304 blend = Blend (FuncAdd,Min) ((One,One),(One,One)) one' 302 blend = Blend (FuncAdd,Min) ((One,One),(One,One)) one
305 fragCtx = accumulationContext (DepthOp Less False, ColorOp blend (one' :: Vec 4 Bool)) 303 fragCtx = accumulationContext (DepthOp Less False, ColorOp blend (one :: Vec 4 Bool))
306 rastCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex 304 rastCtx = TriangleCtx CullNone PolygonFill NoOffset LastVertex
307 input = fetch "missing shader" Triangle (Attribute "position" :: Vec 3 Float, Attribute "color" :: Vec 4 Float) 305 input = fetch "missing shader" Triangle (Attribute "position" :: Vec 3 Float, Attribute "color" :: Vec 4 Float)
308 prims = mapPrimitives vert input 306 prims = mapPrimitives vert input
@@ -323,22 +321,20 @@ errorShader fb = accumulate fragCtx frag rast (errorShaderFill fb)
323 v4 = viewProj *. (worldMat *. snoc p 1) 321 v4 = viewProj *. (worldMat *. snoc p 1)
324 322
325 offset = NoOffset--Offset (0) (-10) 323 offset = NoOffset--Offset (0) (-10)
326 fragCtx = accumulationContext (DepthOp Lequal True, ColorOp NoBlending (one' :: Vec 4 Bool)) 324 fragCtx = accumulationContext (DepthOp Lequal True, ColorOp NoBlending (one :: Vec 4 Bool))
327 rastCtx = TriangleCtx CullNone (PolygonLine 1) offset LastVertex 325 rastCtx = TriangleCtx CullNone (PolygonLine 1) offset LastVertex
328 input = fetch "missing shader" Triangle (Attribute "position" :: Vec 3 Float, Attribute "color" :: Vec 4 Float) 326 input = fetch "missing shader" Triangle (Attribute "position" :: Vec 3 Float, Attribute "color" :: Vec 4 Float)
329 prims = mapPrimitives vert input 327 prims = mapPrimitives vert input
330 rast = rasterizePrimitives rastCtx ((Smooth)) prims 328 rast = rasterizePrimitives rastCtx ((Smooth)) prims
331 329
332-- frag :: Vec 4 Float -> (Depth Float, Color (Vec 4 Float)) 330-- frag :: Vec 4 Float -> (Depth Float, Color (Vec 4 Float))
333 frag = \((v)) -> let 331 frag = \((v)) -> ((V4 (1 - v%r) (1 - v%g) (1 - v%b) 1))
334 one = 1
335 in ((V4 (one -! v%r) (one -! v%g) (one -! v%b) one))
336 332
337q3GFX :: [(String,CommonAttrs)] -> FB 333q3GFX :: [(String,CommonAttrs)] -> FB
338q3GFX shl = {-blurVH $ PrjFrameBuffer "" tix0 $ -}errorShader (foldl' mkShader clear ordered) 334q3GFX shl = {-blurVH $ PrjFrameBuffer "" tix0 $ -}errorShader (foldl' mkShader clear ordered)
339 where 335 where
340 ordered = sortBy (\(_,a) (_,b) -> caSort a `compare` caSort b) shl 336 ordered = sortBy (\(_,a) (_,b) -> caSort a `compare` caSort b) shl
341 clear = FrameBuffer (depthImage1 1000, colorImage1 (zero'::Vec 4 Float)) 337 clear = FrameBuffer (depthImage1 1000, colorImage1 (zero :: Vec 4 Float))
342 338
343--main :: Output 339--main :: Output
344main = ScreenOut (q3GFX sampleMaterial) 340main = ScreenOut (q3GFX sampleMaterial)
diff --git a/testdata/performance/Graphics.out b/testdata/performance/Graphics.out
index fc891b27..52c8a2ed 100644
--- a/testdata/performance/Graphics.out
+++ b/testdata/performance/Graphics.out
@@ -1,5 +1,5 @@
1Pipeline 1Pipeline
2 { info = "generated by lambdcube-compiler 0.5.0.0" 2 { info = "generated by lambdacube-compiler 0.5.0.0"
3 , backend = OpenGL33 3 , backend = OpenGL33
4 , textures = [] 4 , textures = []
5 , samplers = [] 5 , samplers = []
diff --git a/testdata/reject.ignore/adhoc.reject.lc b/testdata/reject.ignore/adhoc.reject.lc
index 42e2d968..659029b6 100644
--- a/testdata/reject.ignore/adhoc.reject.lc
+++ b/testdata/reject.ignore/adhoc.reject.lc
@@ -1,7 +1,7 @@
1 1
2data A = A 2data A = A
3 3
4x = oneComp :: Vec 4 A 4x = one :: Vec 4 A
5 5
6main = x -- TODO: catch error at application 6main = x -- TODO: catch error at application
7 7