summaryrefslogtreecommitdiff
path: root/Definitions.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Definitions.hs')
-rw-r--r--Definitions.hs85
1 files changed, 35 insertions, 50 deletions
diff --git a/Definitions.hs b/Definitions.hs
index d4b69be..9618407 100644
--- a/Definitions.hs
+++ b/Definitions.hs
@@ -1,10 +1,10 @@
1{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
2module Definitions where 2module Definitions (modules) where
3 3
4import Control.Monad.Writer 4import Control.Monad.Writer
5import Language 5import Language
6 6
7ir = execWriter $ do 7ir = do
8 -- type aliases 8 -- type aliases
9 "StreamName" #= Int 9 "StreamName" #= Int
10 "ProgramName" #= Int 10 "ProgramName" #= Int
@@ -118,6 +118,7 @@ ir = execWriter $ do
118 enum_ "UTexture2DMSArray" 118 enum_ "UTexture2DMSArray"
119 enum_ "UTextureBuffer" 119 enum_ "UTextureBuffer"
120 enum_ "UTexture2DRect" 120 enum_ "UTexture2DRect"
121 deriving_ [Haskell] [Eq,Ord]
121 122
122 data_ "PointSpriteCoordOrigin" $ do 123 data_ "PointSpriteCoordOrigin" $ do
123 enum_ "LowerLeft" 124 enum_ "LowerLeft"
@@ -219,9 +220,6 @@ ir = execWriter $ do
219 , "backStencilOp" #:: "StencilOperation" -- Used for back faced triangles. 220 , "backStencilOp" #:: "StencilOperation" -- Used for back faced triangles.
220 ] 221 ]
221 222
222 data_ "StencilTests" $ do
223 const_ "StencilTests" ["StencilTest", "StencilTest"]
224
225 data_ "StencilTest" $ do 223 data_ "StencilTest" $ do
226 constR_ "StencilTest" 224 constR_ "StencilTest"
227 [ "stencilComparision" #:: "ComparisonFunction" -- The function used to compare the @stencilReference@ and the stencil buffers value with. 225 [ "stencilComparision" #:: "ComparisonFunction" -- The function used to compare the @stencilReference@ and the stencil buffers value with.
@@ -229,6 +227,9 @@ ir = execWriter $ do
229 , "stencilMask" #:: Word32 -- A bit mask with ones in each position that should be compared and written to the stencil buffer. 227 , "stencilMask" #:: Word32 -- A bit mask with ones in each position that should be compared and written to the stencil buffer.
230 ] 228 ]
231 229
230 data_ "StencilTests" $ do
231 const_ "StencilTests" ["StencilTest", "StencilTest"]
232
232 -- primitive types 233 -- primitive types
233 data_ "FetchPrimitive" $ do 234 data_ "FetchPrimitive" $ do
234 enum_ "Points" 235 enum_ "Points"
@@ -236,7 +237,7 @@ ir = execWriter $ do
236 enum_ "Triangles" 237 enum_ "Triangles"
237 enum_ "LinesAdjacency" 238 enum_ "LinesAdjacency"
238 enum_ "TrianglesAdjacency" 239 enum_ "TrianglesAdjacency"
239 deriving_ [Show,Eq] 240 deriving_ [PureScript] [Show,Eq]
240 241
241 data_ "OutputPrimitive" $ do 242 data_ "OutputPrimitive" $ do
242 enum_ "TrianglesOutput" 243 enum_ "TrianglesOutput"
@@ -248,7 +249,7 @@ ir = execWriter $ do
248 enum_ "RG" 249 enum_ "RG"
249 enum_ "RGB" 250 enum_ "RGB"
250 enum_ "RGBA" 251 enum_ "RGBA"
251 deriving_ [Show] 252 deriving_ [PureScript] [Show]
252 253
253 data_ "Blending" $ do 254 data_ "Blending" $ do
254 enum_ "NoBlending" 255 enum_ "NoBlending"
@@ -284,7 +285,7 @@ ir = execWriter $ do
284 const_ "IntT" ["ColorArity"] 285 const_ "IntT" ["ColorArity"]
285 const_ "WordT" ["ColorArity"] 286 const_ "WordT" ["ColorArity"]
286 enum_ "ShadowT" 287 enum_ "ShadowT"
287 deriving_ [Show] 288 deriving_ [PureScript] [Show]
288 289
289 data_ "TextureType" $ do 290 data_ "TextureType" $ do
290 const_ "Texture1D" ["TextureDataType", Int] 291 const_ "Texture1D" ["TextureDataType", Int]
@@ -314,14 +315,15 @@ ir = execWriter $ do
314 enum_ "ClampToEdge" 315 enum_ "ClampToEdge"
315 enum_ "ClampToBorder" 316 enum_ "ClampToBorder"
316 317
317 data_ "ImageRef" $ do
318 const_ "TextureImage" ["TextureName", Int, Maybe Int] -- Texture name, mip index, array index
319 const_ "Framebuffer" ["ImageSemantic"]
320
321 data_ "ImageSemantic" $ do 318 data_ "ImageSemantic" $ do
322 enum_ "Depth" 319 enum_ "Depth"
323 enum_ "Stencil" 320 enum_ "Stencil"
324 enum_ "Color" 321 enum_ "Color"
322 deriving_ [Haskell] [Eq]
323
324 data_ "ImageRef" $ do
325 const_ "TextureImage" ["TextureName", Int, Maybe Int] -- Texture name, mip index, array index
326 const_ "Framebuffer" ["ImageSemantic"]
325 327
326 data_ "ClearImage" $ do 328 data_ "ClearImage" $ do
327 constR_ "ClearImage" 329 constR_ "ClearImage"
@@ -344,16 +346,6 @@ ir = execWriter $ do
344 const_ "SaveImage" ["FrameBufferComponent", "ImageRef"] -- from framebuffer component to texture (image) 346 const_ "SaveImage" ["FrameBufferComponent", "ImageRef"] -- from framebuffer component to texture (image)
345 const_ "LoadImage" ["ImageRef", "FrameBufferComponent"] -- from texture (image) to framebuffer component 347 const_ "LoadImage" ["ImageRef", "FrameBufferComponent"] -- from texture (image) to framebuffer component
346 348
347 data_ "TextureDescriptor" $ do -- texture size, type, array, mipmap
348 constR_ "TextureDescriptor"
349 [ "textureType" #:: "TextureType"
350 , "textureSize" #:: "Value"
351 , "textureSemantic" #:: "ImageSemantic"
352 , "textureSampler" #:: "SamplerDescriptor"
353 , "textureBaseLevel" #:: Int
354 , "textureMaxLevel" #:: Int
355 ]
356
357 data_ "SamplerDescriptor" $ do 349 data_ "SamplerDescriptor" $ do
358 constR_ "SamplerDescriptor" 350 constR_ "SamplerDescriptor"
359 [ "samplerWrapS" #:: "EdgeMode" 351 [ "samplerWrapS" #:: "EdgeMode"
@@ -368,6 +360,16 @@ ir = execWriter $ do
368 , "samplerCompareFunc" #:: Maybe "ComparisonFunction" 360 , "samplerCompareFunc" #:: Maybe "ComparisonFunction"
369 ] 361 ]
370 362
363 data_ "TextureDescriptor" $ do -- texture size, type, array, mipmap
364 constR_ "TextureDescriptor"
365 [ "textureType" #:: "TextureType"
366 , "textureSize" #:: "Value"
367 , "textureSemantic" #:: "ImageSemantic"
368 , "textureSampler" #:: "SamplerDescriptor"
369 , "textureBaseLevel" #:: Int
370 , "textureMaxLevel" #:: Int
371 ]
372
371 data_ "Parameter" $ do 373 data_ "Parameter" $ do
372 constR_ "Parameter" 374 constR_ "Parameter"
373 [ "name" #:: String 375 [ "name" #:: String
@@ -428,8 +430,9 @@ ir = execWriter $ do
428 , "streams" #:: Array "StreamData" 430 , "streams" #:: Array "StreamData"
429 , "commands" #:: Array "Command" 431 , "commands" #:: Array "Command"
430 ] 432 ]
433 deriving_ [Haskell] [Show]
431 434
432mesh = execWriter $ do 435mesh = do
433 data_ "MeshAttribute" $ do 436 data_ "MeshAttribute" $ do
434 const_ "A_Float" [Array Float] 437 const_ "A_Float" [Array Float]
435 const_ "A_V2F" [Array v2f] 438 const_ "A_V2F" [Array v2f]
@@ -454,7 +457,7 @@ mesh = execWriter $ do
454 , "mPrimitive" #:: "MeshPrimitive" 457 , "mPrimitive" #:: "MeshPrimitive"
455 ] 458 ]
456 459
457typeInfo = execWriter $ do 460typeInfo = do
458 data_ "TypeInfo" $ do 461 data_ "TypeInfo" $ do
459 constR_ "TypeInfo" 462 constR_ "TypeInfo"
460 [ "startLine" #:: Int 463 [ "startLine" #:: Int
@@ -466,29 +469,11 @@ typeInfo = execWriter $ do
466 469
467 data_ "MyEither" $ do 470 data_ "MyEither" $ do
468 const_ "MyLeft" ["TypeInfo", Array "TypeInfo"] 471 const_ "MyLeft" ["TypeInfo", Array "TypeInfo"]
469 const_ "MyRight" ["TypeInfo"{- "Pipeline" -}, Array "TypeInfo"] 472 const_ "MyRight" ["Pipeline", Array "TypeInfo"]
470 473
471{- 474modules = do
472type TypeInfoRecord = 475 module_ "IR" ir
473 { startLine :: Int 476 module_ "Mesh" mesh
474 , startColumn :: Int 477 module_ "TypeInfo" $ do
475 , endLine :: Int 478 import_ ["IR"]
476 , endColumn :: Int 479 typeInfo
477 , text :: String
478 }
479data TypeInfo = TypeInfo TypeInfoRecord
480
481instance decodeJsonTypeInfo :: DecodeJson TypeInfo where
482 decodeJson json = do
483 obj <- decodeJson json
484 startL <- obj .? "startL"
485 startC <- obj .? "startC"
486 endL <- obj .? "endL"
487 endC <- obj .? "endC"
488 text <- obj .? "text"
489 return $ TypeInfo {startLine:startL, startColumn:startC, endLine:endL, endColumn:endC, text:text}
490
491data MyEither
492 = MyLeft TypeInfo (Array TypeInfo)
493 | MyRight Pipeline (Array TypeInfo)
494-} \ No newline at end of file