Mercurial > games > semicongine
diff examples/E10_pong.nim @ 316:b145a05c2459
add: changing rendering system, not finished yet, also upgrading to Nim 2
author | Sam <sam@basx.dev> |
---|---|
date | Mon, 07 Aug 2023 00:23:00 +0700 |
parents | da0bd61abe91 |
children | 887ddc8d45fd |
line wrap: on
line diff
--- a/examples/E10_pong.nim Sun Jul 23 19:59:47 2023 +0700 +++ b/examples/E10_pong.nim Mon Aug 07 00:23:00 2023 +0700 @@ -31,32 +31,26 @@ level.root.add ball const - vertexInput = @[ + inputs = @[ attr[Vec3f]("position"), attr[Vec4f]("color", memoryPerformanceHint=PreferFastWrite), attr[Mat4]("transform", memoryPerformanceHint=PreferFastWrite, perInstance=true), ] - vertexOutput = @[attr[Vec4f]("outcolor")] + intermediate = @[attr[Vec4f]("outcolor")] uniforms = @[attr[Mat4]("projection")] - fragOutput = @[attr[Vec4f]("color")] - vertexCode = compileGlslShader( - stage=VK_SHADER_STAGE_VERTEX_BIT, - inputs=vertexInput, + outputs = @[attr[Vec4f]("color")] + (vertexCode, fragmentCode) = compileVertexFragmentShaderSet( + inputs=inputs, + intermediate=intermediate, + outputs=outputs, uniforms=uniforms, - outputs=vertexOutput, - main="""outcolor = color; gl_Position = vec4(position, 1) * (transform * Uniforms.projection);""" - ) - fragmentCode = compileGlslShader( - stage=VK_SHADER_STAGE_FRAGMENT_BIT, - inputs=vertexOutput, - uniforms=uniforms, - outputs=fragOutput, - main="color = outcolor;" + vertexCode="""outcolor = color; gl_Position = vec4(position, 1) * (transform * Uniforms.projection);""", + fragmentCode="color = outcolor;", ) # set up rendering myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode, clearColor=backgroundColor)) - myengine.addScene(level, vertexInput, @[], transformAttribute="transform") + myengine.addScene(level, inputs, @[], transformAttribute="transform") level.addShaderGlobal("projection", Unit4f32) var