Mercurial > games > semicongine
comparison examples/E01_hello_triangle.nim @ 671:d84b2e88776a
fix: always use rgba
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 09 May 2023 18:19:17 +0700 |
parents | c33c8e156e3e |
children | 5f7ec8d1bd33 |
comparison
equal
deleted
inserted
replaced
670:881a5c9ea50f | 671:d84b2e88776a |
---|---|
2 | 2 |
3 | 3 |
4 const | 4 const |
5 vertexInput = @[ | 5 vertexInput = @[ |
6 attr[Vec3f]("position"), | 6 attr[Vec3f]("position"), |
7 attr[Vec3f]("color"), | 7 attr[Vec4f]("color"), |
8 ] | 8 ] |
9 vertexOutput = @[attr[Vec3f]("outcolor")] | 9 vertexOutput = @[attr[Vec4f]("outcolor")] |
10 fragOutput = @[attr[Vec4f]("color")] | 10 fragOutput = @[attr[Vec4f]("color")] |
11 vertexCode = compileGlslShader( | 11 vertexCode = compileGlslShader( |
12 stage=VK_SHADER_STAGE_VERTEX_BIT, | 12 stage=VK_SHADER_STAGE_VERTEX_BIT, |
13 inputs=vertexInput, | 13 inputs=vertexInput, |
14 outputs=vertexOutput, | 14 outputs=vertexOutput, |
19 ) | 19 ) |
20 fragmentCode = compileGlslShader( | 20 fragmentCode = compileGlslShader( |
21 stage=VK_SHADER_STAGE_FRAGMENT_BIT, | 21 stage=VK_SHADER_STAGE_FRAGMENT_BIT, |
22 inputs=vertexOutput, | 22 inputs=vertexOutput, |
23 outputs=fragOutput, | 23 outputs=fragOutput, |
24 main="color = vec4(outcolor, 1);" | 24 main="color = outcolor;" |
25 ) | 25 ) |
26 | 26 |
27 var | 27 var |
28 triangle = newScene("scene", newEntity( | 28 triangle = newScene("scene", newEntity( |
29 "triangle", | 29 "triangle", |
30 newMesh( | 30 newMesh( |
31 [newVec3f(-0.5, 0.5), newVec3f(0, -0.5), newVec3f(0.5, 0.5)], | 31 [newVec3f(-0.5, 0.5), newVec3f(0, -0.5), newVec3f(0.5, 0.5)], |
32 [X, Y, Z], | 32 [newVec4f(1, 0, 0, 1), newVec4f(0, 1, 0, 1), newVec4f(0, 0, 1, 1)], |
33 ) | 33 ) |
34 )) | 34 )) |
35 myengine = initEngine("Hello triangle") | 35 myengine = initEngine("Hello triangle") |
36 renderPass = myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode) | 36 renderPass = myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode) |
37 | 37 |