Mercurial > games > semicongine
diff examples/hello_triangle.nim @ 59:d7d9420ba675
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 | 547f3a374271 |
children | c57285d292b6 |
line wrap: on
line diff
--- a/examples/hello_triangle.nim Fri Jan 20 16:36:52 2023 +0700 +++ b/examples/hello_triangle.nim Fri Jan 20 16:53:37 2023 +0700 @@ -7,9 +7,9 @@ type # define type of vertex VertexDataA = object - position: PositionAttribute[TVec2[float32]] - color: ColorAttribute[TVec3[float32]] - id: InstanceAttribute[TVec3[float32]] + position: PositionAttribute[Vec2] + color: ColorAttribute[Vec3] + id: InstanceAttribute[Vec3] var pipeline: RenderPipeline[VertexDataA, void] @@ -19,14 +19,14 @@ # vertex data (types must match the above VertexAttributes) const triangle_pos = @[ - TVec2([ 0.0'f32, -0.5'f32]), - TVec2([ 0.5'f32, 0.5'f32]), - TVec2([-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 = @[ - 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]), + 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]), ] when isMainModule: @@ -35,9 +35,9 @@ # build a mesh var trianglemesh = new Mesh[VertexDataA] trianglemesh.vertexData = VertexDataA( - 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])]), + 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