Mercurial > games > semicongine
diff examples/E01_hello_triangle.nim @ 777:754835bf175e
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 | a4c757f5d17f |
children | 8084252b807a |
line wrap: on
line diff
--- a/examples/E01_hello_triangle.nim Sun Jul 23 19:53:10 2023 +0700 +++ b/examples/E01_hello_triangle.nim Mon Aug 07 00:23:00 2023 +0700 @@ -2,26 +2,21 @@ const - vertexInput = @[ + inputs = @[ attr[Vec3f]("position"), attr[Vec4f]("color"), ] - vertexOutput = @[attr[Vec4f]("outcolor")] - fragOutput = @[attr[Vec4f]("color")] - vertexCode = compileGlslShader( - stage=VK_SHADER_STAGE_VERTEX_BIT, - inputs=vertexInput, - outputs=vertexOutput, - main=""" + intermediate = @[attr[Vec4f]("outcolor")] + outputs = @[attr[Vec4f]("color")] + (vertexCode, fragmentCode) = compileVertexFragmentShaderSet( + inputs=inputs, + intermediate=intermediate, + outputs=outputs, + vertexCode=""" gl_Position = vec4(position, 1.0); outcolor = color; - """ - ) - fragmentCode = compileGlslShader( - stage=VK_SHADER_STAGE_FRAGMENT_BIT, - inputs=vertexOutput, - outputs=fragOutput, - main="color = outcolor;" + """, + fragmentCode="color = outcolor;", ) var @@ -36,7 +31,7 @@ renderPass = myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode) myengine.setRenderer(renderPass) -myengine.addScene(triangle, vertexInput, @[], transformAttribute="") +myengine.addScene(triangle, inputs, @[], transformAttribute="") while myengine.updateInputs() == Running and not myengine.keyWasPressed(Escape): myengine.renderScene(triangle)