diff examples/hello_triangle.nim @ 518:5d406c17bbcb

did: refactor Vector names
author Sam <sam@basx.dev>
date Fri, 20 Jan 2023 16:13:32 +0700
parents 836790efab48
children cd73e429fc99
line wrap: on
line diff
--- a/examples/hello_triangle.nim	Fri Jan 20 00:41:55 2023 +0700
+++ b/examples/hello_triangle.nim	Fri Jan 20 16:13:32 2023 +0700
@@ -7,9 +7,9 @@
 type
   # define type of vertex
   VertexDataA = object
-    position: PositionAttribute[Vec2[float32]]
-    color: ColorAttribute[Vec3[float32]]
-    id: InstanceAttribute[Vec3[float32]]
+    position: PositionAttribute[TVec2[float32]]
+    color: ColorAttribute[TVec3[float32]]
+    id: InstanceAttribute[TVec3[float32]]
 
 var pipeline: RenderPipeline[VertexDataA, void]
 
@@ -19,14 +19,14 @@
 # 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]),
+    TVec2([ 0.0'f32, -0.5'f32]),
+    TVec2([ 0.5'f32,  0.5'f32]),
+    TVec2([-0.5'f32,  0.5'f32]),
   ]
   triangle_color = @[
-    Vec3([1.0'f32, 0.0'f32, 0.0'f32]),
-    Vec3([0.0'f32, 1.0'f32, 0.0'f32]),
-    Vec3([0.0'f32, 0.0'f32, 1.0'f32]),
+    TVec3([1.0'f32, 0.0'f32, 0.0'f32]),
+    TVec3([0.0'f32, 1.0'f32, 0.0'f32]),
+    TVec3([0.0'f32, 0.0'f32, 1.0'f32]),
   ]
 
 when isMainModule:
@@ -35,9 +35,9 @@
   # build a mesh
   var trianglemesh = new Mesh[VertexDataA]
   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])]),
+    position: PositionAttribute[TVec2[float32]](data: triangle_pos),
+    color: ColorAttribute[TVec3[float32]](data: triangle_color),
+    id: InstanceAttribute[TVec3[float32]](data: @[TVec3[float32]([0.5'f32, 0.5'f32, 0.5'f32])]),
   )
   # build a single-object scene graph
   var triangle = new Thing