Mercurial > games > semicongine
comparison examples/squares.nim @ 39:0cb294c5d2fd
fix: hello cube, add: run_all command
| author | Sam <sam@basx.dev> |
|---|---|
| date | Wed, 18 Jan 2023 13:49:12 +0700 |
| parents | c3c963e7c1a6 |
| children | 2771db8d4276 |
comparison
equal
deleted
inserted
replaced
| 38:c3c963e7c1a6 | 39:0cb294c5d2fd |
|---|---|
| 66 iValues[vertIndex + 2] = uint32(squareIndex) | 66 iValues[vertIndex + 2] = uint32(squareIndex) |
| 67 iValues[vertIndex + 3] = uint32(squareIndex) | 67 iValues[vertIndex + 3] = uint32(squareIndex) |
| 68 indices[squareIndex * 2 + 0] = [uint16(vertIndex + 0), uint16(vertIndex + 1), uint16(vertIndex + 2)] | 68 indices[squareIndex * 2 + 0] = [uint16(vertIndex + 0), uint16(vertIndex + 1), uint16(vertIndex + 2)] |
| 69 indices[squareIndex * 2 + 1] = [uint16(vertIndex + 2), uint16(vertIndex + 3), uint16(vertIndex + 0)] | 69 indices[squareIndex * 2 + 1] = [uint16(vertIndex + 2), uint16(vertIndex + 3), uint16(vertIndex + 0)] |
| 70 | 70 |
| 71 var scene = new Thing | |
| 72 | 71 |
| 73 type PIndexedMesh = ref IndexedMesh[VertexDataA, uint16] # required so we can use ctor with ref/on heap | 72 type PIndexedMesh = ref IndexedMesh[VertexDataA, uint16] # required so we can use ctor with ref/on heap |
| 74 var squaremesh = PIndexedMesh( | 73 var squaremesh = PIndexedMesh( |
| 75 vertexData: VertexDataA( | 74 vertexData: VertexDataA( |
| 76 position11: PositionAttribute[Vec2[float32]](data: @vertices), | 75 position11: PositionAttribute[Vec2[float32]](data: @vertices), |
| 77 color22: ColorAttribute[Vec3[float32]](data: @colors), | 76 color22: ColorAttribute[Vec3[float32]](data: @colors), |
| 78 index: GenericAttribute[uint32](data: @iValues), | 77 index: GenericAttribute[uint32](data: @iValues), |
| 79 ), | 78 ), |
| 80 indices: @indices | 79 indices: @indices |
| 81 ) | 80 ) |
| 81 var scene = new Thing | |
| 82 var childthing = new Thing | 82 var childthing = new Thing |
| 83 childthing.parts.add squaremesh | 83 childthing.parts.add squaremesh |
| 84 scene.children.add childthing | 84 scene.children.add childthing |
| 85 | 85 |
| 86 const vertexShader = generateVertexShaderCode[VertexDataA, Uniforms]( | 86 const vertexShader = generateVertexShaderCode[VertexDataA, Uniforms]( |
| 91 v = pow(1 - v, 3000); | 91 v = pow(1 - v, 3000); |
| 92 out_color = vec3(in_color.r, in_color.g, v * 0.5); | 92 out_color = vec3(in_color.r, in_color.g, v * 0.5); |
| 93 """ | 93 """ |
| 94 ) | 94 ) |
| 95 const fragmentShader = generateFragmentShaderCode[VertexDataA]() | 95 const fragmentShader = generateFragmentShaderCode[VertexDataA]() |
| 96 static: | |
| 97 echo "--------------" | |
| 98 for (i, line) in enumerate(vertexShader.splitLines()): | |
| 99 echo $(i + 1) & " " & line | |
| 100 echo "--------------" | |
| 101 pipeline = setupPipeline[VertexDataA, Uniforms, uint16]( | 96 pipeline = setupPipeline[VertexDataA, Uniforms, uint16]( |
| 102 myengine, | 97 myengine, |
| 103 scene, | 98 scene, |
| 104 vertexShader, | 99 vertexShader, |
| 105 fragmentShader | 100 fragmentShader |
