annotate tests/test_vulkan_wrapper.nim @ 1135:74957cbf589b

fix: update tests according to some API renaming
author sam <sam@basx.dev>
date Mon, 03 Jun 2024 16:05:17 +0700
parents 73b572f82a1f
children 71315636ba82
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
bfcb41211c5b add: final font-rendering, API changes fixed
Sam <sam@basx.dev>
parents: 253
diff changeset
1 import std/tables
bfcb41211c5b add: final font-rendering, API changes fixed
Sam <sam@basx.dev>
parents: 253
diff changeset
2
117
40ff2453855e did: small changes from refactoring
Sam <sam@basx.dev>
parents: 115
diff changeset
3 import semicongine
99
4deffc94484a add: vertex and (initial) shader types and methods
Sam <sam@basx.dev>
parents: 98
diff changeset
4
322
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
5
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
6 let
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
7 sampler = Sampler(
322
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
8 magnification: VK_FILTER_NEAREST,
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
9 minification: VK_FILTER_NEAREST,
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
10 wrapModeS: VK_SAMPLER_ADDRESS_MODE_REPEAT,
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
11 wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT,
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
12 )
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
13 (R, W) = ([255'u8, 0'u8, 0'u8, 255'u8], [255'u8, 255'u8, 255'u8, 255'u8])
1021
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
14 Mat1Type = MaterialType(
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
15 name: "single texture material 1",
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
16 vertexAttributes: {
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
17 "color": Vec4F32,
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
18 "position": Vec3F32,
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
19 "uv": Vec2F32,
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
20 }.toTable,
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
21 attributes: {"baseTexture": TextureType}.toTable
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
22 )
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
23 mat = Mat1Type.initMaterialData(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
24 name = "mat",
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
25 attributes = {
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
26 "baseTexture": initDataList(@[Texture(isGrayscale: false, colorImage: Image[RGBAPixel](width: 5, height: 5, imagedata: @[
322
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
27 R, R, R, R, R,
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
28 R, R, W, R, R,
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
29 R, W, W, W, R,
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
30 R, R, W, R, R,
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
31 R, R, R, R, R,
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
32 ]), sampler: sampler)])
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
33 }.toTable
322
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
34 )
376
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
35 Mat2Type = MaterialType(
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
36 name: "single texture material 2",
384
eaf084ba80e5 fix: cleanup when multiple textures use same vulkan image
Sam <sam@basx.dev>
parents: 376
diff changeset
37 vertexAttributes: {
1021
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
38 "color": Vec4F32,
376
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
39 "position": Vec3F32,
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
40 "uv": Vec2F32,
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
41 }.toTable,
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
42 attributes: {"baseTexture": TextureType}.toTable
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
43 )
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
44 mat2 = Mat2Type.initMaterialData(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
45 name = "mat2",
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
46 attributes = {
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
47 "baseTexture": initDataList(@[Texture(isGrayscale: false, colorImage: Image[RGBAPixel](width: 5, height: 5, imagedata: @[
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
48 R, W, R, W, R,
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
49 W, R, W, R, W,
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
50 R, W, R, W, R,
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
51 W, R, W, R, W,
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
52 R, W, R, W, R,
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
53 ]), sampler: sampler)])
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
54 }.toTable
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
55 )
368
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
56 mat3 = SINGLE_COLOR_MATERIAL.initMaterialData(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
57 name = "mat3",
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
58 attributes = {
368
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
59 "color": initDataList(@[newVec4f(0, 1, 0, 1)])
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
60 }.toTable
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
61 )
322
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
62
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
63 proc scene_different_mesh_types(): seq[Mesh] =
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
64 @[
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
65 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
66 positions = [newVec3f(0.0, -0.5), newVec3f(0.5, 0.5), newVec3f(-0.5, 0.5)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
67 uvs = [newVec2f(0.0, -0.5), newVec2f(0.5, 0.5), newVec2f(-0.5, 0.5)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
69 material = mat,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
70 transform = translate(-0.7, -0.5),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
71 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
72 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
73 positions = [newVec3f(0.0, -0.4), newVec3f(0.4, 0.4), newVec3f(-0.4, 0.5)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
74 uvs = [newVec2f(0.0, -0.4), newVec2f(0.4, 0.4), newVec2f(-0.4, 0.5)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
76 material = mat,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
77 transform = translate(0, -0.5),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
78 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
79 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
80 positions = [newVec3f(0.0, 0.5), newVec3f(0.5, -0.5), newVec3f(-0.5, -0.5)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
81 uvs = [newVec2f(0.0, 0.5), newVec2f(0.5, -0.5), newVec2f(-0.5, -0.5)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
83 indices = [[0'u16, 2'u16, 1'u16]],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
84 material = mat2,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
85 transform = translate(0.7, -0.5),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
86 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
87 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
88 positions = [newVec3f(0.0, 0.4), newVec3f(0.4, -0.4), newVec3f(-0.4, -0.4)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
89 uvs = [newVec2f(0.0, 0.4), newVec2f(0.4, -0.4), newVec2f(-0.4, -0.4)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
91 indices = [[0'u16, 2'u16, 1'u16]],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
92 material = mat2,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
93 transform = translate(-0.7, 0.5),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
94 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
95 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
96 positions = [newVec3f(0.4, 0.5), newVec3f(0.9, -0.3), newVec3f(0.0, -0.3)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
97 uvs = [newVec2f(0.4, 0.5), newVec2f(0.9, -0.3), newVec2f(0.0, -0.3)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
99 indices = [[0'u32, 2'u32, 1'u32]],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
100 autoResize = false,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
101 material = mat2,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
102 transform = translate(0, 0.5),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
103 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
104 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
105 positions = [newVec3f(0.4, 0.5), newVec3f(0.9, -0.3), newVec3f(0.0, -0.3)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
106 uvs = [newVec2f(0.4, 0.5), newVec2f(0.9, -0.3), newVec2f(0.0, -0.3)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
108 indices = [[0'u32, 2'u32, 1'u32]],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
109 autoResize = false,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
110 material = mat2,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
111 transform = translate(0.7, 0.5),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
112 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
113 ]
124
cb9e27a30165 fix: completely overhole buffer handling for drawing, fix shit
Sam <sam@basx.dev>
parents: 123
diff changeset
114
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
115 proc scene_simple(): seq[Mesh] =
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
116 @[
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
117 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
118 positions = [newVec3f(0.0, -0.3), newVec3f(0.3, 0.3), newVec3f(-0.3, 0.3)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
120 uvs = [newVec2f(0.0, -0.3), newVec2f(0.3, 0.3), newVec2f(-0.3, 0.3)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
121 material = mat,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
122 transform = translate(0.4, 0.4),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
123 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
124 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
125 positions = [newVec3f(0.0, -0.5), newVec3f(0.5, 0.5), newVec3f(-0.5, 0.5)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
127 uvs = [newVec2f(0.0, -0.5), newVec2f(0.5, 0.5), newVec2f(-0.5, 0.5)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
128 material = mat,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
129 transform = translate(0.4, -0.4),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
130 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
131 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
132 positions = [newVec3f(0.0, -0.6), newVec3f(0.6, 0.6), newVec3f(-0.6, 0.6)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
134 uvs = [newVec2f(0.0, -0.6), newVec2f(0.6, 0.6), newVec2f(-0.6, 0.6)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
135 indices = [[0'u32, 1'u32, 2'u32]],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
136 autoResize = false,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
137 material = mat,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
138 transform = translate(-0.4, 0.4),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
139 ),
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
140 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
141 positions = [newVec3f(0.0, -0.8), newVec3f(0.8, 0.8), newVec3f(-0.8, 0.8)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
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)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
143 uvs = [newVec2f(0.0, -0.8), newVec2f(0.8, 0.8), newVec2f(-0.8, 0.8)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
144 indices = [[0'u16, 1'u16, 2'u16]],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
145 instanceTransforms = [Unit4F32, Unit4F32],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
146 material = mat,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
147 transform = translate(-0.4, -0.4),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
148 )
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
149 ]
124
cb9e27a30165 fix: completely overhole buffer handling for drawing, fix shit
Sam <sam@basx.dev>
parents: 123
diff changeset
150
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
151 proc scene_primitives(): seq[Mesh] =
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
152 var r = rect(color = "ff0000")
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
153 var t = tri(color = "0000ff")
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
154 var c = circle(color = "00ff00")
368
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
155 r.material = mat
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
156 t.material = mat
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
157 c.material = mat
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
158 r.transform = translate(newVec3f(0.5, -0.3))
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
159 t.transform = translate(newVec3f(0.3, 0.3))
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
160 c.transform = translate(newVec3f(-0.3, 0.1))
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
161 result = @[r, c, t]
124
cb9e27a30165 fix: completely overhole buffer handling for drawing, fix shit
Sam <sam@basx.dev>
parents: 123
diff changeset
162
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
163 proc scene_flag(): seq[Mesh] =
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
164 @[
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
165 newMesh(
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
166 positions = [newVec3f(-1.0, -1.0), newVec3f(1.0, -1.0), newVec3f(1.0, 1.0), newVec3f(-1.0, 1.0)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
167 uvs = [newVec2f(-1.0, -1.0), newVec2f(1.0, -1.0), newVec2f(1.0, 1.0), newVec2f(-1.0, 1.0)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
168 colors = [newVec4f(-1, -1, 1, 1), newVec4f(1, -1, 1, 1), newVec4f(1, 1, 1, 1), newVec4f(-1, 1, 1, 1)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
169 indices = [[0'u16, 1'u16, 2'u16], [2'u16, 3'u16, 0'u16]],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
170 material = mat,
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
171 transform = scale(0.5, 0.5)
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
172 )
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
173 ]
192
659992f14dd6 add: textures now support in shader via scene data, also: improved config handling a bit, more to come
Sam <sam@basx.dev>
parents: 191
diff changeset
174
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
175 proc scene_multi_material(): seq[Mesh] =
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
176 var
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
177 r1 = rect(color = "ffffff")
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
178 r2 = rect(color = "000000")
368
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
179 r1.material = mat
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
180 r2.material = mat3
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
181 r1.transform = translate(newVec3f(-0.5))
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
182 r2.transform = translate(newVec3f(+0.5))
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
183 result = @[r1, r2]
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
184
129
15d37022625c add: input handling, small refactoring for renderer
Sam <sam@basx.dev>
parents: 128
diff changeset
185 proc main() =
127
5871acc2977e did: big refactoring
Sam <sam@basx.dev>
parents: 126
diff changeset
186 var engine = initEngine("Test")
124
cb9e27a30165 fix: completely overhole buffer handling for drawing, fix shit
Sam <sam@basx.dev>
parents: 123
diff changeset
187
cb9e27a30165 fix: completely overhole buffer handling for drawing, fix shit
Sam <sam@basx.dev>
parents: 123
diff changeset
188 # INIT RENDERER:
cb9e27a30165 fix: completely overhole buffer handling for drawing, fix shit
Sam <sam@basx.dev>
parents: 123
diff changeset
189 const
324
cbfe96272205 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 323
diff changeset
190 shaderConfiguration1 = createShaderConfiguration(
1021
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
191 name = "shader1",
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
192 inputs = [
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
193 attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead),
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
194 attr[Vec4f]("color", memoryPerformanceHint = PreferFastWrite),
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
195 attr[Mat4]("transform", perInstance = true),
321
30117d8f0052 did next step in renderpipeline-refactoring, using shaderconfiguration objects instead for less ambigious shader-pipeline configuration
Sam <sam@basx.dev>
parents: 316
diff changeset
196 ],
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
197 intermediates = [
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
198 attr[Vec4f]("outcolor"),
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
199 ],
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
200 outputs = [attr[Vec4f]("color")],
1021
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
201 samplers = [attr[Texture]("baseTexture")],
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
202 vertexCode = """gl_Position = vec4(position, 1.0) * transform; outcolor = color;""",
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
203 fragmentCode = "color = texture(baseTexture, outcolor.xy) * 0.5 + outcolor * 0.5;",
124
cb9e27a30165 fix: completely overhole buffer handling for drawing, fix shit
Sam <sam@basx.dev>
parents: 123
diff changeset
204 )
324
cbfe96272205 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 323
diff changeset
205 shaderConfiguration2 = createShaderConfiguration(
1021
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
206 name = "shader2",
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
207 inputs = [
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
208 attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead),
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
209 attr[Mat4]("transform", perInstance = true),
324
cbfe96272205 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 323
diff changeset
210 ],
420
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
211 intermediates = [attr[Vec4f]("outcolor")],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
212 outputs = [attr[Vec4f]("color")],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
213 uniforms = [attr[Vec4f]("color", arrayCount = 1)],
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
214 vertexCode = """gl_Position = vec4(position, 1.0) * transform; outcolor = Uniforms.color[0];""",
91e018270832 fix: all tests (once more)
Sam <sam@basx.dev>
parents: 384
diff changeset
215 fragmentCode = "color = outcolor;",
324
cbfe96272205 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 323
diff changeset
216 )
323
9defff46da48 add: first complete working version of multiple materials and shaders per scene, yipie :)
Sam <sam@basx.dev>
parents: 322
diff changeset
217 engine.initRenderer({
1021
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
218 Mat1Type: shaderConfiguration1,
73b572f82a1f add: bases for a better input-system
sam <sam@basx.dev>
parents: 979
diff changeset
219 Mat1Type: shaderConfiguration1,
376
fa38cd28f041 fix: all tests
Sam <sam@basx.dev>
parents: 371
diff changeset
220 Mat2Type: shaderConfiguration1,
368
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
221 SINGLE_COLOR_MATERIAL: shaderConfiguration2,
344
b83b3a1ccb05 fix: all tests
Sam <sam@basx.dev>
parents: 334
diff changeset
222 })
124
cb9e27a30165 fix: completely overhole buffer handling for drawing, fix shit
Sam <sam@basx.dev>
parents: 123
diff changeset
223
129
15d37022625c add: input handling, small refactoring for renderer
Sam <sam@basx.dev>
parents: 128
diff changeset
224 # INIT SCENES
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 188
diff changeset
225 var scenes = [
328
8d0ffcacc7e3 did: some cleanup
Sam <sam@basx.dev>
parents: 327
diff changeset
226 Scene(name: "simple", meshes: scene_simple()),
8d0ffcacc7e3 did: some cleanup
Sam <sam@basx.dev>
parents: 327
diff changeset
227 Scene(name: "different mesh types", meshes: scene_different_mesh_types()),
8d0ffcacc7e3 did: some cleanup
Sam <sam@basx.dev>
parents: 327
diff changeset
228 Scene(name: "primitives", meshes: scene_primitives()),
8d0ffcacc7e3 did: some cleanup
Sam <sam@basx.dev>
parents: 327
diff changeset
229 Scene(name: "flag", meshes: scene_flag()),
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
230 Scene(name: "multimaterial", meshes: scene_multi_material()),
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 188
diff changeset
231 ]
322
6dab370d1758 add: first, incomplete version of material use
Sam <sam@basx.dev>
parents: 321
diff changeset
232
128
9901ec3831d1 did: finish refactoring of render pipeline, yipi! :)
Sam <sam@basx.dev>
parents: 127
diff changeset
233 for scene in scenes.mitems:
368
51ee41c1d8ed fix: first example to work correctly with new material system
Sam <sam@basx.dev>
parents: 353
diff changeset
234 engine.loadScene(scene)
109
8d24727c9795 did: refactor rendering/scene concept
Sam <sam@basx.dev>
parents: 108
diff changeset
235
115
e18538442837 add: comments for further refactoring
Sam <sam@basx.dev>
parents: 114
diff changeset
236 # MAINLOOP
111
6fd10b7e2d6a did: allow runtime shader-input definitions
Sam <sam@basx.dev>
parents: 109
diff changeset
237 echo "Setup successfull, start rendering"
128
9901ec3831d1 did: finish refactoring of render pipeline, yipi! :)
Sam <sam@basx.dev>
parents: 127
diff changeset
238 for i in 0 ..< 3:
189
df92519d4d68 add: initial code for texture support, not finished, had to completely refactor how to handle material-data (ie scene-wide data, sorry if you ever read this
Sam <sam@basx.dev>
parents: 188
diff changeset
239 for scene in scenes.mitems:
326
4ec852355750 fix: many issues, better mesh-handling, still need to cope with different binding numbers when using different pipelines...
Sam <sam@basx.dev>
parents: 325
diff changeset
240 echo "rendering scene ", scene.name
128
9901ec3831d1 did: finish refactoring of render pipeline, yipi! :)
Sam <sam@basx.dev>
parents: 127
diff changeset
241 for i in 0 ..< 1000:
1135
74957cbf589b fix: update tests according to some API renaming
sam <sam@basx.dev>
parents: 1021
diff changeset
242 if not engine.UpdateInputs() or KeyIsDown(Escape):
129
15d37022625c add: input handling, small refactoring for renderer
Sam <sam@basx.dev>
parents: 128
diff changeset
243 engine.destroy()
15d37022625c add: input handling, small refactoring for renderer
Sam <sam@basx.dev>
parents: 128
diff changeset
244 return
131
11666d28e04d add: recreation of swapchain (at least on linux, windows will likely fail, needs testing
Sam <sam@basx.dev>
parents: 129
diff changeset
245 engine.renderScene(scene)
114
056e08dfad10 yay: first triangle rendering with new engine implmentation
Sam <sam@basx.dev>
parents: 113
diff changeset
246
056e08dfad10 yay: first triangle rendering with new engine implmentation
Sam <sam@basx.dev>
parents: 113
diff changeset
247 # cleanup
96
b9fc90de1450 add: swapchain API, more refactoring
Sam <sam@basx.dev>
parents: 94
diff changeset
248 echo "Start cleanup"
127
5871acc2977e did: big refactoring
Sam <sam@basx.dev>
parents: 126
diff changeset
249 engine.destroy()
129
15d37022625c add: input handling, small refactoring for renderer
Sam <sam@basx.dev>
parents: 128
diff changeset
250
15d37022625c add: input handling, small refactoring for renderer
Sam <sam@basx.dev>
parents: 128
diff changeset
251 when isMainModule:
15d37022625c add: input handling, small refactoring for renderer
Sam <sam@basx.dev>
parents: 128
diff changeset
252 main()