Mercurial > games > semicongine
comparison tests/test_materials.nim @ 1139:114f395b9144
did: finish refactoring and updated all tests accordingly
| author | sam <sam@basx.dev> |
|---|---|
| date | Sat, 08 Jun 2024 14:58:25 +0700 |
| parents | 02e1d2658ff5 |
| children |
comparison
equal
deleted
inserted
replaced
| 1138:02e1d2658ff5 | 1139:114f395b9144 |
|---|---|
| 11 WT, WT, WT, WT, WT, WT, WT, | 11 WT, WT, WT, WT, WT, WT, WT, |
| 12 PT, PT, PT, PT, PT, PT, PT, | 12 PT, PT, PT, PT, PT, PT, PT, |
| 13 WT, WT, WT, WT, WT, WT, WT, | 13 WT, WT, WT, WT, WT, WT, WT, |
| 14 RT, RT, RT, RT, RT, RT, RT, | 14 RT, RT, RT, RT, RT, RT, RT, |
| 15 ]) | 15 ]) |
| 16 swiss = loadImage[RGBAPixel]("flag.png") | 16 swiss = LoadImage[RGBAPixel]("flag.png") |
| 17 doubleTextureMaterial = MaterialType( | 17 doubleTextureMaterial = MaterialType( |
| 18 name: "Double texture", | 18 name: "Double texture", |
| 19 vertexAttributes: { | 19 vertexAttributes: { |
| 20 "position": Vec3F32, | 20 "position": Vec3F32, |
| 21 "uv": Vec2F32, | 21 "uv": Vec2F32, |
| 22 }.toTable, | 22 }.toTable, |
| 23 attributes: {"tex1": TextureType, "tex2": TextureType}.toTable | 23 attributes: {"tex1": TextureType, "tex2": TextureType}.toTable |
| 24 ) | 24 ) |
| 25 material = initMaterialData( | 25 material = InitMaterialData( |
| 26 theType = doubleTextureMaterial, | 26 theType = doubleTextureMaterial, |
| 27 name = "swiss-thai", | 27 name = "swiss-thai", |
| 28 attributes = { | 28 attributes = { |
| 29 "tex1": InitDataList(@[Texture(colorImage: thai, sampler: sampler, isGrayscale: false)]), | 29 "tex1": InitDataList(@[Texture(colorImage: thai, sampler: sampler, isGrayscale: false)]), |
| 30 "tex2": InitDataList(@[Texture(colorImage: swiss, sampler: sampler, isGrayscale: false)]), | 30 "tex2": InitDataList(@[Texture(colorImage: swiss, sampler: sampler, isGrayscale: false)]), |
| 31 } | 31 } |
| 32 ) | 32 ) |
| 33 | 33 |
| 34 proc main() = | 34 proc main() = |
| 35 var flag = rect() | 35 var flag = Rect() |
| 36 flag.material = material | 36 flag.material = material |
| 37 var scene = Scene(name: "main", meshes: @[flag]) | 37 var scene = Scene(name: "main", meshes: @[flag]) |
| 38 scene.addShaderGlobalArray("test2", @[NewVec4f(), NewVec4f()]) | 38 scene.AddShaderGlobalArray("test2", @[NewVec4f(), NewVec4f()]) |
| 39 | 39 |
| 40 var engine = InitEngine("Test materials") | 40 var engine = InitEngine("Test materials") |
| 41 | 41 |
| 42 const | 42 const |
| 43 shaderConfiguration1 = createShaderConfiguration( | 43 shaderConfiguration1 = CreateShaderConfiguration( |
| 44 name = "shader 1", | 44 name = "shader 1", |
| 45 inputs = [ | 45 inputs = [ |
| 46 Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), | 46 Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), |
| 47 Attr[Vec2f]("uv", memoryPerformanceHint = PreferFastRead), | 47 Attr[Vec2f]("uv", memoryPerformanceHint = PreferFastRead), |
| 48 ], | 48 ], |
| 68 }) | 68 }) |
| 69 engine.LoadScene(scene) | 69 engine.LoadScene(scene) |
| 70 var t = cpuTime() | 70 var t = cpuTime() |
| 71 while engine.UpdateInputs() and not KeyIsDown(Escape): | 71 while engine.UpdateInputs() and not KeyIsDown(Escape): |
| 72 var d = float32(cpuTime() - t) | 72 var d = float32(cpuTime() - t) |
| 73 setShaderGlobalArray(scene, "test2", @[NewVec4f(d), NewVec4f(d * 2)]) | 73 SetShaderGlobalArray(scene, "test2", @[NewVec4f(d), NewVec4f(d * 2)]) |
| 74 engine.RenderScene(scene) | 74 engine.RenderScene(scene) |
| 75 engine.Destroy() | 75 engine.Destroy() |
| 76 | 76 |
| 77 | 77 |
| 78 when isMainModule: | 78 when isMainModule: |
