Mercurial > games > semicongine
comparison examples/E04_input.nim @ 671:d84b2e88776a
fix: always use rgba
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 09 May 2023 18:19:17 +0700 |
parents | c33c8e156e3e |
children | 3bb199dd45ba |
comparison
equal
deleted
inserted
replaced
670:881a5c9ea50f | 671:d84b2e88776a |
---|---|
22 [2.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.8, -1.3, 1.0], | 22 [2.6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.8, -1.3, 1.0], |
23 [1.5, 1.5, 1.5, 6, 1.5, 1.5, -1.2, 1.5, -0.1, 1.0, 1.0, 1.0], | 23 [1.5, 1.5, 1.5, 6, 1.5, 1.5, -1.2, 1.5, -0.1, 1.0, 1.0, 1.0], |
24 ) | 24 ) |
25 keyDimension = 50'f32 | 25 keyDimension = 50'f32 |
26 keyGap = 10'f32 | 26 keyGap = 10'f32 |
27 backgroundColor = newVec3f(0.6705882352941176, 0.6078431372549019, 0.5882352941176471) | 27 backgroundColor = newVec4f(0.6705882352941176, 0.6078431372549019, 0.5882352941176471, 1) |
28 baseColor = newVec3f(0.9411764705882353, 0.9058823529411765, 0.8470588235294118'f32) | 28 baseColor = newVec4f(0.9411764705882353, 0.9058823529411765, 0.8470588235294118, 1) |
29 activeColor = newVec3f(0.6509803921568628'f32, 0.22745098039215686, 0.3137254901960784'f32) | 29 activeColor = newVec4f(0.6509803921568628, 0.22745098039215686, 0.3137254901960784, 1) |
30 arrow_colors = @[ | 30 arrow_colors = @[ |
31 baseColor * 0.9'f32, | 31 baseColor * 0.9'f32, |
32 baseColor * 0.9'f32, | 32 baseColor * 0.9'f32, |
33 baseColor * 0.9'f32, | 33 baseColor * 0.9'f32, |
34 baseColor * 0.8'f32, | 34 baseColor * 0.8'f32, |
56 | 56 |
57 # build keyboard and cursor meshes | 57 # build keyboard and cursor meshes |
58 var | 58 var |
59 scene: Scene | 59 scene: Scene |
60 keyvertexpos: seq[Vec3f] | 60 keyvertexpos: seq[Vec3f] |
61 keyvertexcolor: seq[Vec3f] | 61 keyvertexcolor: seq[Vec4f] |
62 keymeshindices: seq[array[3, uint16]] | 62 keymeshindices: seq[array[3, uint16]] |
63 rowpos = newVec2f(0, 0) | 63 rowpos = newVec2f(0, 0) |
64 i = 0'u16 | 64 i = 0'u16 |
65 firstRow = true | 65 firstRow = true |
66 rowWidth = 0'f32 | 66 rowWidth = 0'f32 |
147 | 147 |
148 # shaders | 148 # shaders |
149 const | 149 const |
150 vertexInput = @[ | 150 vertexInput = @[ |
151 attr[Vec3f]("position"), | 151 attr[Vec3f]("position"), |
152 attr[Vec3f]("color", memoryPerformanceHint=PreferFastWrite), | 152 attr[Vec4f]("color", memoryPerformanceHint=PreferFastWrite), |
153 attr[Mat4]("transform", memoryPerformanceHint=PreferFastWrite, perInstance=true), | 153 attr[Mat4]("transform", memoryPerformanceHint=PreferFastWrite, perInstance=true), |
154 ] | 154 ] |
155 vertexOutput = @[attr[Vec3f]("outcolor")] | 155 vertexOutput = @[attr[Vec4f]("outcolor")] |
156 uniforms = @[attr[Mat4]("projection")] | 156 uniforms = @[attr[Mat4]("projection")] |
157 fragOutput = @[attr[Vec4f]("color")] | 157 fragOutput = @[attr[Vec4f]("color")] |
158 vertexCode = compileGlslShader( | 158 vertexCode = compileGlslShader( |
159 stage=VK_SHADER_STAGE_VERTEX_BIT, | 159 stage=VK_SHADER_STAGE_VERTEX_BIT, |
160 inputs=vertexInput, | 160 inputs=vertexInput, |
165 fragmentCode = compileGlslShader( | 165 fragmentCode = compileGlslShader( |
166 stage=VK_SHADER_STAGE_FRAGMENT_BIT, | 166 stage=VK_SHADER_STAGE_FRAGMENT_BIT, |
167 inputs=vertexOutput, | 167 inputs=vertexOutput, |
168 uniforms=uniforms, | 168 uniforms=uniforms, |
169 outputs=fragOutput, | 169 outputs=fragOutput, |
170 main="color = vec4(outcolor, 1);" | 170 main="color = outcolor;" |
171 ) | 171 ) |
172 | 172 |
173 # set up rendering | 173 # set up rendering |
174 myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode, clearColor=newVec4f(0, 0, 0.5))) | 174 myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode, clearColor=newVec4f(0, 0, 0.5))) |
175 myengine.addScene(scene, vertexInput, transformAttribute="transform") | 175 myengine.addScene(scene, vertexInput, transformAttribute="transform") |