comparison examples/hello_cube.nim @ 519:03a94b905f1a

did: refactor Matrix names
author Sam <sam@basx.dev>
date Fri, 20 Jan 2023 16:36:52 +0700
parents 5d406c17bbcb
children d7d9420ba675
comparison
equal deleted inserted replaced
518:5d406c17bbcb 519:03a94b905f1a
18 # define type of vertex 18 # define type of vertex
19 VertexDataA = object 19 VertexDataA = object
20 position: PositionAttribute[TVec3[float32]] 20 position: PositionAttribute[TVec3[float32]]
21 color: ColorAttribute[TVec3[float32]] 21 color: ColorAttribute[TVec3[float32]]
22 Uniforms = object 22 Uniforms = object
23 model: Descriptor[Mat44[float32]] 23 model: Descriptor[TMat44[float32]]
24 view: Descriptor[Mat44[float32]] 24 view: Descriptor[TMat44[float32]]
25 projection: Descriptor[Mat44[float32]] 25 projection: Descriptor[TMat44[float32]]
26 26
27 var 27 var
28 pipeline: RenderPipeline[VertexDataA, Uniforms] 28 pipeline: RenderPipeline[VertexDataA, Uniforms]
29 uniforms:Uniforms 29 uniforms:Uniforms
30 t: float32 30 t: float32
34 let ratio = float32(engine.vulkan.frameDimension.height) / float32(engine.vulkan.frameDimension.width) 34 let ratio = float32(engine.vulkan.frameDimension.height) / float32(engine.vulkan.frameDimension.width)
35 t += dt 35 t += dt
36 uniforms.model.value = translate3d(0'f32, 0'f32, 10'f32) * rotate3d(t, Yf32) # * rotate3d(float32(PI), Yf32) 36 uniforms.model.value = translate3d(0'f32, 0'f32, 10'f32) * rotate3d(t, Yf32) # * rotate3d(float32(PI), Yf32)
37 37
38 uniforms.view.value = Unit44f32 38 uniforms.view.value = Unit44f32
39 uniforms.projection.value = Mat44[float32](data:[ 39 uniforms.projection.value = TMat44[float32](data:[
40 ratio, 0'f32, 0'f32, 0'f32, 40 ratio, 0'f32, 0'f32, 0'f32,
41 0'f32, 1'f32, 0'f32, 0'f32, 41 0'f32, 1'f32, 0'f32, 0'f32,
42 0'f32, 0'f32, 1'f32, 0'f32, 42 0'f32, 0'f32, 1'f32, 0'f32,
43 0'f32, 0'f32, 0'f32, 1'f32, 43 0'f32, 0'f32, 0'f32, 1'f32,
44 ]) 44 ])