Mercurial > games > semicongine
comparison examples/E02_squares.nim @ 137:ac2b6777c5db
add: some cleanup, discovered bug
author | Sam <sam@basx.dev> |
---|---|
date | Fri, 21 Apr 2023 00:29:09 +0700 |
parents | fc5db4f1f94e |
children | 34112bf5abf8 |
comparison
equal
deleted
inserted
replaced
136:fc5db4f1f94e | 137:ac2b6777c5db |
---|---|
45 | 45 |
46 | 46 |
47 const | 47 const |
48 vertexInput = @[ | 48 vertexInput = @[ |
49 attr[Vec3f]("position", memoryLocation=VRAM), | 49 attr[Vec3f]("position", memoryLocation=VRAM), |
50 attr[Vec3f]("color", memoryLocation=VRAM), # TODO: VRAMVisible | 50 attr[Vec3f]("color", memoryLocation=VRAM), |
51 attr[uint32]("index", memoryLocation=VRAM), | 51 attr[uint32]("index", memoryLocation=VRAM), |
52 ] | 52 ] |
53 vertexOutput = @[attr[Vec3f]("outcolor")] | 53 vertexOutput = @[attr[Vec3f]("outcolor")] |
54 uniforms = @[attr[float32]("time")] | 54 uniforms = @[attr[float32]("time")] |
55 fragOutput = @[attr[Vec4f]("color")] | 55 fragOutput = @[attr[Vec4f]("color")] |
78 positions=vertices, | 78 positions=vertices, |
79 indices=indices, | 79 indices=indices, |
80 colors=colors, | 80 colors=colors, |
81 ) | 81 ) |
82 setMeshData[uint32](squaremesh, "index", iValues.toSeq) | 82 setMeshData[uint32](squaremesh, "index", iValues.toSeq) |
83 var i = 0'u64 | |
84 var (p, l) = squaremesh.getRawData("color") | |
85 while i < uint64(l): | |
86 echo (cast[ptr float32]((cast[uint64](p) + i)))[] | |
87 inc i | |
83 | 88 |
84 var myengine = initEngine("Squares") | 89 var myengine = initEngine("Squares") |
85 myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) | 90 myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)) |
86 | 91 |
87 var scene = newEntity("scene", newEntity("squares", squaremesh)) | 92 var scene = newEntity("scene", newEntity("squares", squaremesh)) |