Mercurial > games > semicongine
comparison tests/test_vulkan_wrapper.nim @ 1136:71315636ba82
did: refactor naming in tons of places
author | sam <sam@basx.dev> |
---|---|
date | Tue, 04 Jun 2024 16:51:50 +0700 |
parents | 74957cbf589b |
children | a4aa9f374d44 |
comparison
equal
deleted
inserted
replaced
1135:74957cbf589b | 1136:71315636ba82 |
---|---|
54 }.toTable | 54 }.toTable |
55 ) | 55 ) |
56 mat3 = SINGLE_COLOR_MATERIAL.initMaterialData( | 56 mat3 = SINGLE_COLOR_MATERIAL.initMaterialData( |
57 name = "mat3", | 57 name = "mat3", |
58 attributes = { | 58 attributes = { |
59 "color": initDataList(@[newVec4f(0, 1, 0, 1)]) | 59 "color": initDataList(@[NewVec4f(0, 1, 0, 1)]) |
60 }.toTable | 60 }.toTable |
61 ) | 61 ) |
62 | 62 |
63 proc scene_different_mesh_types(): seq[Mesh] = | 63 proc scene_different_mesh_types(): seq[Mesh] = |
64 @[ | 64 @[ |
65 newMesh( | 65 newMesh( |
66 positions = [newVec3f(0.0, -0.5), newVec3f(0.5, 0.5), newVec3f(-0.5, 0.5)], | 66 positions = [NewVec3f(0.0, -0.5), NewVec3f(0.5, 0.5), NewVec3f(-0.5, 0.5)], |
67 uvs = [newVec2f(0.0, -0.5), newVec2f(0.5, 0.5), newVec2f(-0.5, 0.5)], | 67 uvs = [NewVec2f(0.0, -0.5), NewVec2f(0.5, 0.5), NewVec2f(-0.5, 0.5)], |
68 colors = [newVec4f(1.0, 0.0, 0.0, 1), newVec4f(0.0, 1.0, 0.0, 1), newVec4f(0.0, 0.0, 1.0, 1)], | 68 colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], |
69 material = mat, | 69 material = mat, |
70 transform = translate(-0.7, -0.5), | 70 transform = Translate(-0.7, -0.5), |
71 ), | 71 ), |
72 newMesh( | 72 newMesh( |
73 positions = [newVec3f(0.0, -0.4), newVec3f(0.4, 0.4), newVec3f(-0.4, 0.5)], | 73 positions = [NewVec3f(0.0, -0.4), NewVec3f(0.4, 0.4), NewVec3f(-0.4, 0.5)], |
74 uvs = [newVec2f(0.0, -0.4), newVec2f(0.4, 0.4), newVec2f(-0.4, 0.5)], | 74 uvs = [NewVec2f(0.0, -0.4), NewVec2f(0.4, 0.4), NewVec2f(-0.4, 0.5)], |
75 colors = [newVec4f(1.0, 0.0, 0.0, 1), newVec4f(0.0, 1.0, 0.0, 1), newVec4f(0.0, 0.0, 1.0, 1)], | 75 colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], |
76 material = mat, | 76 material = mat, |
77 transform = translate(0, -0.5), | 77 transform = Translate(0, -0.5), |
78 ), | 78 ), |
79 newMesh( | 79 newMesh( |
80 positions = [newVec3f(0.0, 0.5), newVec3f(0.5, -0.5), newVec3f(-0.5, -0.5)], | 80 positions = [NewVec3f(0.0, 0.5), NewVec3f(0.5, -0.5), NewVec3f(-0.5, -0.5)], |
81 uvs = [newVec2f(0.0, 0.5), newVec2f(0.5, -0.5), newVec2f(-0.5, -0.5)], | 81 uvs = [NewVec2f(0.0, 0.5), NewVec2f(0.5, -0.5), NewVec2f(-0.5, -0.5)], |
82 colors = [newVec4f(1.0, 0.0, 0.0, 1), newVec4f(0.0, 1.0, 0.0, 1), newVec4f(0.0, 0.0, 1.0, 1)], | 82 colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], |
83 indices = [[0'u16, 2'u16, 1'u16]], | 83 indices = [[0'u16, 2'u16, 1'u16]], |
84 material = mat2, | 84 material = mat2, |
85 transform = translate(0.7, -0.5), | 85 transform = Translate(0.7, -0.5), |
86 ), | 86 ), |
87 newMesh( | 87 newMesh( |
88 positions = [newVec3f(0.0, 0.4), newVec3f(0.4, -0.4), newVec3f(-0.4, -0.4)], | 88 positions = [NewVec3f(0.0, 0.4), NewVec3f(0.4, -0.4), NewVec3f(-0.4, -0.4)], |
89 uvs = [newVec2f(0.0, 0.4), newVec2f(0.4, -0.4), newVec2f(-0.4, -0.4)], | 89 uvs = [NewVec2f(0.0, 0.4), NewVec2f(0.4, -0.4), NewVec2f(-0.4, -0.4)], |
90 colors = [newVec4f(1.0, 0.0, 0.0, 1), newVec4f(0.0, 1.0, 0.0, 1), newVec4f(0.0, 0.0, 1.0, 1)], | 90 colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], |
91 indices = [[0'u16, 2'u16, 1'u16]], | 91 indices = [[0'u16, 2'u16, 1'u16]], |
92 material = mat2, | 92 material = mat2, |
93 transform = translate(-0.7, 0.5), | 93 transform = Translate(-0.7, 0.5), |
94 ), | 94 ), |
95 newMesh( | 95 newMesh( |
96 positions = [newVec3f(0.4, 0.5), newVec3f(0.9, -0.3), newVec3f(0.0, -0.3)], | 96 positions = [NewVec3f(0.4, 0.5), NewVec3f(0.9, -0.3), NewVec3f(0.0, -0.3)], |
97 uvs = [newVec2f(0.4, 0.5), newVec2f(0.9, -0.3), newVec2f(0.0, -0.3)], | 97 uvs = [NewVec2f(0.4, 0.5), NewVec2f(0.9, -0.3), NewVec2f(0.0, -0.3)], |
98 colors = [newVec4f(1.0, 1.0, 0.0, 1), newVec4f(1.0, 1.0, 0.0, 1), newVec4f(1.0, 1.0, 0.0, 1)], | 98 colors = [NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1)], |
99 indices = [[0'u32, 2'u32, 1'u32]], | 99 indices = [[0'u32, 2'u32, 1'u32]], |
100 autoResize = false, | 100 autoResize = false, |
101 material = mat2, | 101 material = mat2, |
102 transform = translate(0, 0.5), | 102 transform = Translate(0, 0.5), |
103 ), | 103 ), |
104 newMesh( | 104 newMesh( |
105 positions = [newVec3f(0.4, 0.5), newVec3f(0.9, -0.3), newVec3f(0.0, -0.3)], | 105 positions = [NewVec3f(0.4, 0.5), NewVec3f(0.9, -0.3), NewVec3f(0.0, -0.3)], |
106 uvs = [newVec2f(0.4, 0.5), newVec2f(0.9, -0.3), newVec2f(0.0, -0.3)], | 106 uvs = [NewVec2f(0.4, 0.5), NewVec2f(0.9, -0.3), NewVec2f(0.0, -0.3)], |
107 colors = [newVec4f(1.0, 1.0, 0.0, 1), newVec4f(1.0, 1.0, 0.0, 1), newVec4f(1.0, 1.0, 0.0, 1)], | 107 colors = [NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1)], |
108 indices = [[0'u32, 2'u32, 1'u32]], | 108 indices = [[0'u32, 2'u32, 1'u32]], |
109 autoResize = false, | 109 autoResize = false, |
110 material = mat2, | 110 material = mat2, |
111 transform = translate(0.7, 0.5), | 111 transform = Translate(0.7, 0.5), |
112 ), | 112 ), |
113 ] | 113 ] |
114 | 114 |
115 proc scene_simple(): seq[Mesh] = | 115 proc scene_simple(): seq[Mesh] = |
116 @[ | 116 @[ |
117 newMesh( | 117 newMesh( |
118 positions = [newVec3f(0.0, -0.3), newVec3f(0.3, 0.3), newVec3f(-0.3, 0.3)], | 118 positions = [NewVec3f(0.0, -0.3), NewVec3f(0.3, 0.3), NewVec3f(-0.3, 0.3)], |
119 colors = [newVec4f(1.0, 0.0, 0.0, 1), newVec4f(0.0, 1.0, 0.0, 1), newVec4f(0.0, 0.0, 1.0, 1)], | 119 colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], |
120 uvs = [newVec2f(0.0, -0.3), newVec2f(0.3, 0.3), newVec2f(-0.3, 0.3)], | 120 uvs = [NewVec2f(0.0, -0.3), NewVec2f(0.3, 0.3), NewVec2f(-0.3, 0.3)], |
121 material = mat, | 121 material = mat, |
122 transform = translate(0.4, 0.4), | 122 transform = Translate(0.4, 0.4), |
123 ), | 123 ), |
124 newMesh( | 124 newMesh( |
125 positions = [newVec3f(0.0, -0.5), newVec3f(0.5, 0.5), newVec3f(-0.5, 0.5)], | 125 positions = [NewVec3f(0.0, -0.5), NewVec3f(0.5, 0.5), NewVec3f(-0.5, 0.5)], |
126 colors = [newVec4f(1.0, 0.0, 0.0, 1), newVec4f(0.0, 1.0, 0.0, 1), newVec4f(0.0, 0.0, 1.0, 1)], | 126 colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], |
127 uvs = [newVec2f(0.0, -0.5), newVec2f(0.5, 0.5), newVec2f(-0.5, 0.5)], | 127 uvs = [NewVec2f(0.0, -0.5), NewVec2f(0.5, 0.5), NewVec2f(-0.5, 0.5)], |
128 material = mat, | 128 material = mat, |
129 transform = translate(0.4, -0.4), | 129 transform = Translate(0.4, -0.4), |
130 ), | 130 ), |
131 newMesh( | 131 newMesh( |
132 positions = [newVec3f(0.0, -0.6), newVec3f(0.6, 0.6), newVec3f(-0.6, 0.6)], | 132 positions = [NewVec3f(0.0, -0.6), NewVec3f(0.6, 0.6), NewVec3f(-0.6, 0.6)], |
133 colors = [newVec4f(1.0, 1.0, 0.0, 1), newVec4f(1.0, 1.0, 0.0, 1), newVec4f(1.0, 1.0, 0.0, 1)], | 133 colors = [NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1)], |
134 uvs = [newVec2f(0.0, -0.6), newVec2f(0.6, 0.6), newVec2f(-0.6, 0.6)], | 134 uvs = [NewVec2f(0.0, -0.6), NewVec2f(0.6, 0.6), NewVec2f(-0.6, 0.6)], |
135 indices = [[0'u32, 1'u32, 2'u32]], | 135 indices = [[0'u32, 1'u32, 2'u32]], |
136 autoResize = false, | 136 autoResize = false, |
137 material = mat, | 137 material = mat, |
138 transform = translate(-0.4, 0.4), | 138 transform = Translate(-0.4, 0.4), |
139 ), | 139 ), |
140 newMesh( | 140 newMesh( |
141 positions = [newVec3f(0.0, -0.8), newVec3f(0.8, 0.8), newVec3f(-0.8, 0.8)], | 141 positions = [NewVec3f(0.0, -0.8), NewVec3f(0.8, 0.8), NewVec3f(-0.8, 0.8)], |
142 colors = [newVec4f(0.0, 0.0, 1.0, 1), newVec4f(0.0, 0.0, 1.0, 1), newVec4f(0.0, 0.0, 1.0, 1)], | 142 colors = [NewVec4f(0.0, 0.0, 1.0, 1), NewVec4f(0.0, 0.0, 1.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], |
143 uvs = [newVec2f(0.0, -0.8), newVec2f(0.8, 0.8), newVec2f(-0.8, 0.8)], | 143 uvs = [NewVec2f(0.0, -0.8), NewVec2f(0.8, 0.8), NewVec2f(-0.8, 0.8)], |
144 indices = [[0'u16, 1'u16, 2'u16]], | 144 indices = [[0'u16, 1'u16, 2'u16]], |
145 instanceTransforms = [Unit4F32, Unit4F32], | 145 instanceTransforms = [Unit4F32, Unit4F32], |
146 material = mat, | 146 material = mat, |
147 transform = translate(-0.4, -0.4), | 147 transform = Translate(-0.4, -0.4), |
148 ) | 148 ) |
149 ] | 149 ] |
150 | 150 |
151 proc scene_primitives(): seq[Mesh] = | 151 proc scene_primitives(): seq[Mesh] = |
152 var r = rect(color = "ff0000") | 152 var r = rect(color = "ff0000") |
153 var t = tri(color = "0000ff") | 153 var t = tri(color = "0000ff") |
154 var c = circle(color = "00ff00") | 154 var c = circle(color = "00ff00") |
155 r.material = mat | 155 r.material = mat |
156 t.material = mat | 156 t.material = mat |
157 c.material = mat | 157 c.material = mat |
158 r.transform = translate(newVec3f(0.5, -0.3)) | 158 r.transform = Translate(NewVec3f(0.5, -0.3)) |
159 t.transform = translate(newVec3f(0.3, 0.3)) | 159 t.transform = Translate(NewVec3f(0.3, 0.3)) |
160 c.transform = translate(newVec3f(-0.3, 0.1)) | 160 c.transform = Translate(NewVec3f(-0.3, 0.1)) |
161 result = @[r, c, t] | 161 result = @[r, c, t] |
162 | 162 |
163 proc scene_flag(): seq[Mesh] = | 163 proc scene_flag(): seq[Mesh] = |
164 @[ | 164 @[ |
165 newMesh( | 165 newMesh( |
166 positions = [newVec3f(-1.0, -1.0), newVec3f(1.0, -1.0), newVec3f(1.0, 1.0), newVec3f(-1.0, 1.0)], | 166 positions = [NewVec3f(-1.0, -1.0), NewVec3f(1.0, -1.0), NewVec3f(1.0, 1.0), NewVec3f(-1.0, 1.0)], |
167 uvs = [newVec2f(-1.0, -1.0), newVec2f(1.0, -1.0), newVec2f(1.0, 1.0), newVec2f(-1.0, 1.0)], | 167 uvs = [NewVec2f(-1.0, -1.0), NewVec2f(1.0, -1.0), NewVec2f(1.0, 1.0), NewVec2f(-1.0, 1.0)], |
168 colors = [newVec4f(-1, -1, 1, 1), newVec4f(1, -1, 1, 1), newVec4f(1, 1, 1, 1), newVec4f(-1, 1, 1, 1)], | 168 colors = [NewVec4f(-1, -1, 1, 1), NewVec4f(1, -1, 1, 1), NewVec4f(1, 1, 1, 1), NewVec4f(-1, 1, 1, 1)], |
169 indices = [[0'u16, 1'u16, 2'u16], [2'u16, 3'u16, 0'u16]], | 169 indices = [[0'u16, 1'u16, 2'u16], [2'u16, 3'u16, 0'u16]], |
170 material = mat, | 170 material = mat, |
171 transform = scale(0.5, 0.5) | 171 transform = Scale(0.5, 0.5) |
172 ) | 172 ) |
173 ] | 173 ] |
174 | 174 |
175 proc scene_multi_material(): seq[Mesh] = | 175 proc scene_multi_material(): seq[Mesh] = |
176 var | 176 var |
177 r1 = rect(color = "ffffff") | 177 r1 = rect(color = "ffffff") |
178 r2 = rect(color = "000000") | 178 r2 = rect(color = "000000") |
179 r1.material = mat | 179 r1.material = mat |
180 r2.material = mat3 | 180 r2.material = mat3 |
181 r1.transform = translate(newVec3f(-0.5)) | 181 r1.transform = Translate(NewVec3f(-0.5)) |
182 r2.transform = translate(newVec3f(+0.5)) | 182 r2.transform = Translate(NewVec3f(+0.5)) |
183 result = @[r1, r2] | 183 result = @[r1, r2] |
184 | 184 |
185 proc main() = | 185 proc main() = |
186 var engine = initEngine("Test") | 186 var engine = initEngine("Test") |
187 | 187 |