comparison tests/test_vulkan_wrapper.nim @ 192:659992f14dd6

add: textures now support in shader via scene data, also: improved config handling a bit, more to come
author Sam <sam@basx.dev>
date Sat, 06 May 2023 23:06:33 +0700
parents 81dc05b46b85
children 744285b47a4d
comparison
equal deleted inserted replaced
191:81dc05b46b85 192:659992f14dd6
98 98
99 proc scene_primitives(): Entity = 99 proc scene_primitives(): Entity =
100 var r = rect(color="ff0000") 100 var r = rect(color="ff0000")
101 var t = tri(color="0000ff") 101 var t = tri(color="0000ff")
102 var c = circle(color="00ff00") 102 var c = circle(color="00ff00")
103 setInstanceData[Vec3f](r, "translate", @[newVec3f(0.5, -0.3)]) 103 r.setInstanceData("translate", @[newVec3f(0.5, -0.3)])
104 setInstanceData[Vec3f](t, "translate", @[newVec3f(0.3, 0.3)]) 104 t.setInstanceData("translate", @[newVec3f(0.3, 0.3)])
105 setInstanceData[Vec3f](c, "translate", @[newVec3f(-0.3, 0.1)]) 105 c.setInstanceData("translate", @[newVec3f(-0.3, 0.1)])
106 result = newEntity("root", t, r, c) 106 result = newEntity("root", t, r, c)
107
108 proc scene_flag(): Entity =
109 var r = rect(color="ff0000")
110 r.updateMeshData("color", @[newVec3f(0, 0), newVec3f(1, 0), newVec3f(1, 1), newVec3f(0, 1)])
111 result = newEntity("root", r)
107 112
108 proc main() = 113 proc main() =
109 var engine = initEngine("Test") 114 var engine = initEngine("Test")
110 115
111 # INIT RENDERER: 116 # INIT RENDERER:
140 145
141 # INIT SCENES 146 # INIT SCENES
142 var scenes = [ 147 var scenes = [
143 newScene("simple", scene_simple()), 148 newScene("simple", scene_simple()),
144 newScene("different mesh types", scene_different_mesh_types()), 149 newScene("different mesh types", scene_different_mesh_types()),
145 newScene("primitives", scene_primitives()) 150 newScene("primitives", scene_primitives()),
151 newScene("flag", scene_flag()),
146 ] 152 ]
147 for scene in scenes.mitems: 153 for scene in scenes.mitems:
148 scene.addShaderGlobal("time", 0.0'f32) 154 scene.addShaderGlobal("time", 0.0'f32)
149 let (R, W) = ([0'u8, 0'u8, 0'u8, 0'u8], [0'u8, 0'u8, 0'u8, 0'u8]) 155 let (R, W) = ([255'u8, 0'u8, 0'u8, 255'u8], [255'u8, 255'u8, 255'u8, 255'u8])
150 scene.addTexture("my_little_texture", TextureImage(width: 5, height: 5, imagedata: @[ 156 scene.addTexture("my_little_texture", TextureImage(width: 5, height: 5, imagedata: @[
151 R, R, R, R, R, 157 R, R, R, R, R,
152 R, R, R, R, R, 158 R, R, W, R, R,
153 R, R, R, R, R, 159 R, W, W, W, R,
154 R, R, R, R, R, 160 R, R, W, R, R,
155 R, R, R, R, R, 161 R, R, R, R, R,
156 ])) 162 ]))
157 engine.addScene(scene, vertexInput) 163 engine.addScene(scene, vertexInput)
158 164
159 # MAINLOOP 165 # MAINLOOP