comparison examples/E04_input.nim @ 71:53ccd6090116

did: cleanup + auto-generate mvp-transformartion in shader code
author Sam <sam@basx.dev>
date Sun, 05 Feb 2023 11:39:11 +0700
parents d830a1c0f86e
children 779607656b12
comparison
equal deleted inserted replaced
70:02bc1232905c 71:53ccd6090116
1 import std/tables
2 import std/enumerate 1 import std/enumerate
3 import std/strutils 2 import std/strutils
4 import std/typetraits 3 import std/typetraits
5 import std/times 4 import std/times
6 import std/math 5 import std/math
12 VertexDataA = object 11 VertexDataA = object
13 position: PositionAttribute[Vec3] 12 position: PositionAttribute[Vec3]
14 color: ColorAttribute[Vec4] 13 color: ColorAttribute[Vec4]
15 transform: ModelTransformAttribute 14 transform: ModelTransformAttribute
16 Uniforms = object 15 Uniforms = object
17 projection: Descriptor[Mat44] 16 projection: ViewProjectionTransform
18 17
19 const 18 const
20 arrow = @[ 19 arrow = @[
21 Vec3([-1'f32, -1'f32, 0'f32]), 20 Vec3([-1'f32, -1'f32, 0'f32]),
22 Vec3([1'f32, -1'f32, 0'f32]), 21 Vec3([1'f32, -1'f32, 0'f32]),
211 tupleLen(keyRows) * (keyDimension + keyGap) - keyGap) / 2'f32, 0'f32) 210 tupleLen(keyRows) * (keyDimension + keyGap) - keyGap) / 2'f32, 0'f32)
212 scene.add newThing("keyboard-center", keyboard) 211 scene.add newThing("keyboard-center", keyboard)
213 scene.add newThing("cursor", cursormesh) 212 scene.add newThing("cursor", cursormesh)
214 213
215 # upload data, prepare shaders, etc 214 # upload data, prepare shaders, etc
216 const vertexShader = generateVertexShaderCode[VertexDataA, Uniforms](""" 215 const vertexShader = generateVertexShaderCode[VertexDataA, Uniforms]()
217 out_position = uniforms.projection * transform * vec4(position, 1);
218 """)
219 const fragmentShader = generateFragmentShaderCode[VertexDataA]() 216 const fragmentShader = generateFragmentShaderCode[VertexDataA]()
220 pipeline = setupPipeline[VertexDataA, Uniforms, uint16]( 217 pipeline = setupPipeline[VertexDataA, Uniforms, uint16](
221 myengine, 218 myengine,
222 scene, 219 scene,
223 vertexShader, 220 vertexShader,