-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphicsPipeline.hs
97 lines (86 loc) · 1.97 KB
/
GraphicsPipeline.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{-# LANGUAGE OverloadedStrings #-}
module GraphicsPipeline where
import Data.Bitmap
import Data.ByteString.Char8 (ByteString)
import Data.Int
import Data.Vect
import Data.Vect.Float.Instances ()
import qualified Data.Vector.Storable as V
data AttributeType
= AT_Float
| AT_Vec2
| AT_Vec3
| AT_Vec4
| AT_Mat2
| AT_Mat3
| AT_Mat4
| AT_Int
| AT_Word
deriving (Eq,Ord,Show)
data Attribute
= A_Float (V.Vector Float)
| A_Vec2 (V.Vector Vec2)
| A_Vec3 (V.Vector Vec3)
| A_Vec4 (V.Vector Vec4)
| A_Mat2 (V.Vector Mat2)
| A_Mat3 (V.Vector Mat3)
| A_Mat4 (V.Vector Mat4)
| A_Int (V.Vector Int32)
| A_Word (V.Vector Word32)
deriving (Eq,Show)
data UniformType
= UT_Float
| UT_Vec2
| UT_Vec3
| UT_Vec4
| UT_Int
| UT_Word
| UT_Bool
| UT_Mat2
| UT_Mat3
| UT_Mat4
deriving (Eq,Ord,Show)
data SamplerType
= ST_Sampler2D
deriving (Eq,Ord,Show)
data Uniform
= U_Float Float
| U_Vec2 Vec2
| U_Vec3 Vec3
| U_Vec4 Vec4
| U_Int Int32
| U_Word Word32
| U_Bool Bool
| U_Mat2 Mat2
| U_Mat3 Mat3
| U_Mat4 Mat4
{-
required texture types:
- depth (float)
- rgb (float)
-}
data RenderBufferType
= RBT_RGB8
data Program
= Program
{ attributes :: [(ByteString,AttributeType)]
, uniforms :: [(ByteString,UniformType)]
, samplers :: [(ByteString,SamplerType)]
, outputs :: [RenderBufferType]
, vertexShader :: [ByteString]
, geometryShader :: [ByteString]
, fragmentShader :: [ByteString]
}
data Primitive
= Points
| TriangleStrip
| Triangles
| TriangleStripI (V.Vector Int)
| TrianglesI (V.Vector Int)
deriving (Eq,Show)
data Mesh
= Mesh
{ mAttributes :: [(ByteString,Attribute)]
, mPrimitive :: Primitive
}
deriving (Eq,Show)