Mercurial > games > semicongine
changeset 529:eb92723db7b2
fix: API changes
author | Sam <sam@basx.dev> |
---|---|
date | Sun, 05 Feb 2023 00:28:18 +0700 |
parents | 3ec1be39e1ad |
children | cfa230e1f3b9 |
files | examples/E01_hello_triangle.nim examples/E02_squares.nim examples/E03_hello_cube.nim |
diffstat | 3 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/E01_hello_triangle.nim Sun Feb 05 00:20:07 2023 +0700 +++ b/examples/E01_hello_triangle.nim Sun Feb 05 00:28:18 2023 +0700 @@ -32,7 +32,7 @@ var myengine = igniteEngine("Hello triangle") # build a mesh - var trianglemesh = new Mesh[VertexDataA] + var trianglemesh = new Mesh[VertexDataA, uint16] trianglemesh.vertexData = VertexDataA( position: PositionAttribute[Vec2](data: triangle_pos), color: ColorAttribute[Vec3](data: triangle_color), @@ -43,7 +43,7 @@ # upload data, prepare shaders, etc const vertexShader = generateVertexShaderCode[VertexDataA, void]() const fragmentShader = generateFragmentShaderCode[VertexDataA]() - pipeline = setupPipeline[VertexDataA, void, void]( + pipeline = setupPipeline[VertexDataA, void, uint16]( myengine, triangle, vertexShader,
--- a/examples/E02_squares.nim Sun Feb 05 00:20:07 2023 +0700 +++ b/examples/E02_squares.nim Sun Feb 05 00:28:18 2023 +0700 @@ -61,7 +61,7 @@ 3), uint16(vertIndex + 0)] - type PIndexedMesh = IndexedMesh[VertexDataA, + type PIndexedMesh = Mesh[VertexDataA, uint16] # required so we can use ctor with ref/on heap var squaremesh = PIndexedMesh( vertexData: VertexDataA( @@ -69,6 +69,7 @@ color22: ColorAttribute[Vec3](data: @colors), index: GenericAttribute[uint32](data: @iValues), ), + indexed: true, indices: @indices ) var scene = newThing("scene", newThing("squares", squaremesh)) @@ -79,10 +80,12 @@ float t = sin(uniforms.t * 0.5) * 0.5 + 0.5; float v = min(1, max(0, pow(pos_weight - t, 2))); v = pow(1 - v, 3000); - out_color = vec3(in_color.r, in_color.g, v * 0.5); + out_color = vec4(in_color.r, in_color.g, v * 0.5, 1.0); """ ) const fragmentShader = generateFragmentShaderCode[VertexDataA]() + static: + echo vertexShader pipeline = setupPipeline[VertexDataA, Uniforms, uint16]( myengine, scene,
--- a/examples/E03_hello_cube.nim Sun Feb 05 00:20:07 2023 +0700 +++ b/examples/E03_hello_cube.nim Sun Feb 05 00:28:18 2023 +0700 @@ -85,7 +85,8 @@ var myengine = igniteEngine("Hello cube") # build a mesh - var trianglemesh = new IndexedMesh[VertexDataA, uint16] + var trianglemesh = new Mesh[VertexDataA, uint16] + trianglemesh.indexed = true trianglemesh.vertexData = VertexDataA( position: PositionAttribute[Vec3](data: cube_pos), color: ColorAttribute[Vec3](data: cube_color),