Mercurial > games > semicongine
comparison tests/test_vulkan_wrapper.nim @ 584:9e7bcc8e0e52
did: refactor mesh code, prepare for instance-data
author | Sam <sam@basx.dev> |
---|---|
date | Mon, 10 Apr 2023 00:53:16 +0700 |
parents | 90537a8887ae |
children | cb9e27a30165 |
comparison
equal
deleted
inserted
replaced
583:90537a8887ae | 584:9e7bcc8e0e52 |
---|---|
55 # INIT RENDERER: | 55 # INIT RENDERER: |
56 const | 56 const |
57 vertexInput = @[ | 57 vertexInput = @[ |
58 attr[Vec3f]("position"), | 58 attr[Vec3f]("position"), |
59 attr[Vec3f]("color"), | 59 attr[Vec3f]("color"), |
60 attr[Mat4]("transform", perInstance=true) | 60 attr[Vec3f]("translate", perInstance=true) |
61 ] | 61 ] |
62 vertexOutput = @[attr[Vec3f]("outcolor")] | 62 vertexOutput = @[attr[Vec3f]("outcolor")] |
63 uniforms = @[attr[float32]("time")] | 63 uniforms = @[attr[float32]("time")] |
64 fragOutput = @[attr[Vec4f]("color")] | 64 fragOutput = @[attr[Vec4f]("color")] |
65 vertexCode = compileGlslShader( | 65 vertexCode = compileGlslShader( |
85 if res != VK_SUCCESS: | 85 if res != VK_SUCCESS: |
86 raise newException(Exception, "Unable to create swapchain") | 86 raise newException(Exception, "Unable to create swapchain") |
87 | 87 |
88 # INIT SCENE | 88 # INIT SCENE |
89 var time = initShaderGlobal("time", 0.0'f32) | 89 var time = initShaderGlobal("time", 0.0'f32) |
90 #[ | |
90 var thescene = Scene( | 91 var thescene = Scene( |
91 name: "main", | 92 name: "main", |
92 root: newEntity("root", | 93 root: newEntity("root", |
93 newEntity("stuff", time), | 94 newEntity("stuff", time), |
94 newEntity("triangle1", newMesh( | 95 newEntity("triangle1", newMesh( |
121 indices=[[0'u32, 2'u32, 1'u32]], | 122 indices=[[0'u32, 2'u32, 1'u32]], |
122 autoResize=false | 123 autoResize=false |
123 )), | 124 )), |
124 ) | 125 ) |
125 ) | 126 ) |
127 ]# | |
128 var mymesh = newMesh( | |
129 positions=[newVec3f(0.0, -0.5), newVec3f(0.5, 0.5), newVec3f(-0.5, 0.5)], | |
130 colors=[newVec3f(1.0, 0.0, 0.0), newVec3f(0.0, 1.0, 0.0), newVec3f(0.0, 0.0, 1.0)], | |
131 ) | |
132 setInstanceData[Vec3f](mymesh, "translate", @[newVec3f(0.3, 0.3)]) | |
133 var thescene = Scene( | |
134 name: "main", | |
135 root: newEntity("root", | |
136 newEntity("stuff", time), | |
137 newEntity("triangle", mymesh), | |
138 ) | |
139 ) | |
126 thescene.setupDrawables(renderPass) | 140 thescene.setupDrawables(renderPass) |
127 swapchain.setupUniforms(thescene) | 141 swapchain.setupUniforms(thescene) |
128 | 142 |
129 # MAINLOOP | 143 # MAINLOOP |
130 echo "Setup successfull, start rendering" | 144 echo "Setup successfull, start rendering" |