diff tests/test_vulkan_wrapper.nim @ 123:55be3579dc30

did: refactor mesh code, prepare for instance-data
author Sam <sam@basx.dev>
date Mon, 10 Apr 2023 00:53:16 +0700
parents 506090173619
children cb9e27a30165
line wrap: on
line diff
--- a/tests/test_vulkan_wrapper.nim	Sun Apr 09 01:04:54 2023 +0700
+++ b/tests/test_vulkan_wrapper.nim	Mon Apr 10 00:53:16 2023 +0700
@@ -57,7 +57,7 @@
     vertexInput = @[
       attr[Vec3f]("position"),
       attr[Vec3f]("color"),
-      attr[Mat4]("transform", perInstance=true)
+      attr[Vec3f]("translate", perInstance=true)
     ]
     vertexOutput = @[attr[Vec3f]("outcolor")]
     uniforms = @[attr[float32]("time")]
@@ -87,6 +87,7 @@
 
   # INIT SCENE
   var time = initShaderGlobal("time", 0.0'f32)
+  #[
   var thescene = Scene(
     name: "main",
     root: newEntity("root",
@@ -123,6 +124,19 @@
       )),
     )
   )
+  ]#
+  var mymesh = newMesh(
+    positions=[newVec3f(0.0, -0.5), newVec3f(0.5, 0.5), newVec3f(-0.5, 0.5)],
+    colors=[newVec3f(1.0, 0.0, 0.0), newVec3f(0.0, 1.0, 0.0), newVec3f(0.0, 0.0, 1.0)],
+  )
+  setInstanceData[Vec3f](mymesh, "translate", @[newVec3f(0.3, 0.3)])
+  var thescene = Scene(
+    name: "main",
+    root: newEntity("root",
+      newEntity("stuff", time),
+      newEntity("triangle", mymesh),
+    )
+  )
   thescene.setupDrawables(renderPass)
   swapchain.setupUniforms(thescene)