diff examples/hello_triangle.nim @ 496:b41733878bc6

add: support for instance data
author Sam <sam@basx.dev>
date Mon, 16 Jan 2023 00:35:41 +0700
parents 0c18638c7217
children 3f1111f3b9f8
line wrap: on
line diff
--- a/examples/hello_triangle.nim	Mon Jan 16 00:03:20 2023 +0700
+++ b/examples/hello_triangle.nim	Mon Jan 16 00:35:41 2023 +0700
@@ -17,6 +17,7 @@
   VertexDataA = object
     position: PositionAttribute[Vec2[float32]]
     color: ColorAttribute[Vec3[float32]]
+    id: InstanceAttribute[Vec3[float32]]
 
 var pipeline: RenderPipeline[VertexDataA, void]
 
@@ -44,6 +45,7 @@
   trianglemesh.vertexData = VertexDataA(
     position: PositionAttribute[Vec2[float32]](data: triangle_pos),
     color: ColorAttribute[Vec3[float32]](data: triangle_color),
+    id: InstanceAttribute[Vec3[float32]](data: @[Vec3[float32]([0.5'f32, 0.5'f32, 0.5'f32])]),
   )
   # build a single-object scene graph
   var triangle = new Thing
@@ -51,9 +53,7 @@
   triangle.parts.add trianglemesh
 
   # upload data, prepare shaders, etc
-  const vertexShader = generateVertexShaderCode[VertexDataA, void](
-    # "out_position = uniforms.mat * vec4(in_position, 0, 1);"
-  )
+  const vertexShader = generateVertexShaderCode[VertexDataA, void]()
   const fragmentShader = generateFragmentShaderCode[VertexDataA]()
   pipeline = setupPipeline[VertexDataA, void, uint16](
     myengine,