diff examples/hello_triangle.nim @ 521:a25325bec7f2

did: deep refactoring of handling vertrex attribute and buffer updates, don't ask ;(
author Sam <sam@basx.dev>
date Sun, 22 Jan 2023 22:46:53 +0700
parents cd73e429fc99
children
line wrap: on
line diff
--- a/examples/hello_triangle.nim	Fri Jan 20 16:53:37 2023 +0700
+++ b/examples/hello_triangle.nim	Sun Jan 22 22:46:53 2023 +0700
@@ -9,7 +9,6 @@
   VertexDataA = object
     position: PositionAttribute[Vec2]
     color: ColorAttribute[Vec3]
-    id: InstanceAttribute[Vec3]
 
 var pipeline: RenderPipeline[VertexDataA, void]
 
@@ -19,9 +18,9 @@
 # vertex data (types must match the above VertexAttributes)
 const
   triangle_pos = @[
-    Vec2([ 0.0'f32, -0.5'f32]),
-    Vec2([ 0.5'f32,  0.5'f32]),
-    Vec2([-0.5'f32,  0.5'f32]),
+    Vec2([0.0'f32, -0.5'f32]),
+    Vec2([0.5'f32, 0.5'f32]),
+    Vec2([-0.5'f32, 0.5'f32]),
   ]
   triangle_color = @[
     Vec3([1.0'f32, 0.0'f32, 0.0'f32]),
@@ -37,12 +36,9 @@
   trianglemesh.vertexData = VertexDataA(
     position: PositionAttribute[Vec2](data: triangle_pos),
     color: ColorAttribute[Vec3](data: triangle_color),
-    id: InstanceAttribute[Vec3](data: @[Vec3([0.5'f32, 0.5'f32, 0.5'f32])]),
   )
   # build a single-object scene graph
-  var triangle = new Thing
-  # add the triangle mesh to the object
-  triangle.parts.add trianglemesh
+  var triangle = newThing("triangle", trianglemesh)
 
   # upload data, prepare shaders, etc
   const vertexShader = generateVertexShaderCode[VertexDataA, void]()