Mercurial > games > semicongine
comparison tests/test_vulkan_wrapper.nim @ 581:87e500bd528a
add: better mesh support, indexed mesh
author | Sam <sam@basx.dev> |
---|---|
date | Thu, 06 Apr 2023 00:30:48 +0700 |
parents | 13febe7978e5 |
children | dfaddaf96f09 |
comparison
equal
deleted
inserted
replaced
580:3c4be9e13570 | 581:87e500bd528a |
---|---|
47 # create devices | 47 # create devices |
48 let selectedPhysicalDevice = instance.getPhysicalDevices().filterBestGraphics() | 48 let selectedPhysicalDevice = instance.getPhysicalDevices().filterBestGraphics() |
49 var device = instance.createDevice( | 49 var device = instance.createDevice( |
50 selectedPhysicalDevice, | 50 selectedPhysicalDevice, |
51 @[], | 51 @[], |
52 @[], | 52 @["VK_EXT_index_type_uint8"], |
53 selectedPhysicalDevice.filterForGraphicsPresentationQueues() | 53 selectedPhysicalDevice.filterForGraphicsPresentationQueues() |
54 ) | 54 ) |
55 | 55 |
56 # INIT RENDERER: | 56 # INIT RENDERER: |
57 const | 57 const |
88 root: newEntity("root", | 88 root: newEntity("root", |
89 newEntity("triangle1", newMesh( | 89 newEntity("triangle1", newMesh( |
90 positions=[newVec3f(0.0, -0.5), newVec3f(0.5, 0.5), newVec3f(-0.5, 0.5)], | 90 positions=[newVec3f(0.0, -0.5), newVec3f(0.5, 0.5), newVec3f(-0.5, 0.5)], |
91 colors=[newVec3f(1.0, 0.0, 0.0), newVec3f(0.0, 1.0, 0.0), newVec3f(0.0, 0.0, 1.0)], | 91 colors=[newVec3f(1.0, 0.0, 0.0), newVec3f(0.0, 1.0, 0.0), newVec3f(0.0, 0.0, 1.0)], |
92 )), | 92 )), |
93 newEntity("triangle1b", newMesh( | |
94 positions=[newVec3f(0.0, -0.4), newVec3f(0.4, 0.4), newVec3f(-0.4, 0.5)], | |
95 colors=[newVec3f(1.0, 0.0, 0.0), newVec3f(0.0, 1.0, 0.0), newVec3f(0.0, 0.0, 1.0)], | |
96 )), | |
97 newEntity("triangle2a", newMesh( | |
98 positions=[newVec3f(0.0, 0.5), newVec3f(0.5, -0.5), newVec3f(-0.5, -0.5)], | |
99 colors=[newVec3f(1.0, 0.0, 0.0), newVec3f(0.0, 1.0, 0.0), newVec3f(0.0, 0.0, 1.0)], | |
100 indices=[[0'u16, 2'u16, 1'u16]] | |
101 )), | |
102 newEntity("triangle2b", newMesh( | |
103 positions=[newVec3f(0.0, 0.4), newVec3f(0.4, -0.4), newVec3f(-0.4, -0.4)], | |
104 colors=[newVec3f(1.0, 0.0, 0.0), newVec3f(0.0, 1.0, 0.0), newVec3f(0.0, 0.0, 1.0)], | |
105 indices=[[0'u16, 2'u16, 1'u16]] | |
106 )), | |
107 newEntity("triangle3a", newMesh( | |
108 positions=[newVec3f(0.4, 0.5), newVec3f(0.9, -0.3), newVec3f(0.0, -0.3)], | |
109 colors=[newVec3f(1.0, 1.0, 0.0), newVec3f(1.0, 1.0, 0.0), newVec3f(1.0, 1.0, 0.0)], | |
110 indices=[[0'u32, 2'u32, 1'u32]], | |
111 autoResize=false | |
112 )), | |
113 newEntity("triangle3b", newMesh( | |
114 positions=[newVec3f(0.4, 0.5), newVec3f(0.9, -0.3), newVec3f(0.0, -0.3)], | |
115 colors=[newVec3f(1.0, 1.0, 0.0), newVec3f(1.0, 1.0, 0.0), newVec3f(1.0, 1.0, 0.0)], | |
116 indices=[[0'u32, 2'u32, 1'u32]], | |
117 autoResize=false | |
118 )), | |
93 ) | 119 ) |
94 ) | 120 ) |
95 thescene.setupDrawables(renderPass) | 121 thescene.setupDrawables(renderPass) |
96 | 122 |
97 # MAINLOOP | 123 # MAINLOOP |
98 echo "Setup successfull, start rendering" | 124 echo "Setup successfull, start rendering" |
99 for i in 0 ..< 1000: | 125 for i in 0 ..< 10000: |
100 discard swapchain.drawScene(thescene) | 126 discard swapchain.drawScene(thescene) |
101 echo "Rendered ", swapchain.framesRendered, " frames" | 127 echo "Rendered ", swapchain.framesRendered, " frames" |
102 checkVkResult device.vk.vkDeviceWaitIdle() | 128 checkVkResult device.vk.vkDeviceWaitIdle() |
103 | 129 |
104 # cleanup | 130 # cleanup |