diff examples/input.nim @ 520:cd73e429fc99

did: use new vector and matrix names for simpler code
author Sam <sam@basx.dev>
date Fri, 20 Jan 2023 16:53:37 +0700
parents 03a94b905f1a
children c57285d292b6
line wrap: on
line diff
--- a/examples/input.nim	Fri Jan 20 16:36:52 2023 +0700
+++ b/examples/input.nim	Fri Jan 20 16:53:37 2023 +0700
@@ -7,12 +7,12 @@
 type
   # define type of vertex
   VertexDataA = object
-    position: PositionAttribute[TVec2[float32]]
-    color: ColorAttribute[TVec3[float32]]
+    position: PositionAttribute[Vec2]
+    color: ColorAttribute[Vec3]
     iscursor: GenericAttribute[int32]
   Uniforms = object
-    projection: Descriptor[TMat44[float32]]
-    cursor: Descriptor[TVec2[float32]]
+    projection: Descriptor[Mat44]
+    cursor: Descriptor[Vec2]
 
 var
   pipeline: RenderPipeline[VertexDataA, Uniforms]
@@ -35,20 +35,20 @@
 # vertex data (types must match the above VertexAttributes)
 const
   shape = @[
-    TVec2([-  1'f32, -  1'f32]),
-    TVec2([   1'f32, -  1'f32]),
-    TVec2([-0.3'f32, -0.3'f32]),
-    TVec2([-0.3'f32, -0.3'f32]),
-    TVec2([-  1'f32,    1'f32]),
-    TVec2([-  1'f32, -  1'f32]),
+    Vec2([-  1'f32, -  1'f32]),
+    Vec2([   1'f32, -  1'f32]),
+    Vec2([-0.3'f32, -0.3'f32]),
+    Vec2([-0.3'f32, -0.3'f32]),
+    Vec2([-  1'f32,    1'f32]),
+    Vec2([-  1'f32, -  1'f32]),
   ]
   colors = @[
-    TVec3([1'f32, 0'f32, 0'f32]),
-    TVec3([1'f32, 0'f32, 0'f32]),
-    TVec3([1'f32, 0'f32, 0'f32]),
-    TVec3([0.8'f32, 0'f32, 0'f32]),
-    TVec3([0.8'f32, 0'f32, 0'f32]),
-    TVec3([0.8'f32, 0'f32, 0'f32]),
+    Vec3([1'f32, 0'f32, 0'f32]),
+    Vec3([1'f32, 0'f32, 0'f32]),
+    Vec3([1'f32, 0'f32, 0'f32]),
+    Vec3([0.8'f32, 0'f32, 0'f32]),
+    Vec3([0.8'f32, 0'f32, 0'f32]),
+    Vec3([0.8'f32, 0'f32, 0'f32]),
   ]
 
 when isMainModule:
@@ -58,8 +58,8 @@
   var cursor = new Thing
   var cursormesh = new Mesh[VertexDataA]
   cursormesh.vertexData = VertexDataA(
-    position: PositionAttribute[TVec2[float32]](data: shape),
-    color: ColorAttribute[TVec3[float32]](data: colors),
+    position: PositionAttribute[Vec2](data: shape),
+    color: ColorAttribute[Vec3](data: colors),
     iscursor: GenericAttribute[int32](data: @[1'i32, 1'i32, 1'i32, 1'i32, 1'i32, 1'i32]),
   )
   # transform the cursor a bit to make it look nice
@@ -71,15 +71,15 @@
       scale2d(0.5'f32, 1'f32) *
       rotate2d(float32(PI) / 4'f32)
     )
-    let pos = TVec3[float32]([cursormesh.vertexData.position.data[i][0], cursormesh.vertexData.position.data[i][1], 1'f32])
+    let pos = Vec3([cursormesh.vertexData.position.data[i][0], cursormesh.vertexData.position.data[i][1], 1'f32])
     cursormesh.vertexData.position.data[i] = (cursorscale * pos).xy
   cursor.parts.add cursormesh
 
   var box = new Thing
   var boxmesh = new Mesh[VertexDataA]
   boxmesh.vertexData = VertexDataA(
-    position: PositionAttribute[TVec2[float32]](data: shape),
-    color: ColorAttribute[TVec3[float32]](data: colors),
+    position: PositionAttribute[Vec2](data: shape),
+    color: ColorAttribute[Vec3](data: colors),
     iscursor: GenericAttribute[int32](data: @[1'i32, 1'i32, 1'i32, 1'i32, 1'i32, 1'i32]),
   )