Mercurial > games > semicongine
comparison tests/test_vulkan_wrapper.nim @ 560:8de8a2102071
add: vertex and (initial) shader types and methods
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 14 Mar 2023 13:21:40 +0700 |
parents | baaa620887b4 |
children | c782d7e52b25 |
comparison
equal
deleted
inserted
replaced
559:baaa620887b4 | 560:8de8a2102071 |
---|---|
1 import std/options | 1 import std/options |
2 | 2 |
3 import semicongine/vulkan | 3 import semicongine/vulkan |
4 import semicongine/platform/window | 4 import semicongine/platform/window |
5 import semicongine/math | 5 import semicongine/math |
6 | |
7 type | |
8 Vertex = object | |
9 pos: Vec3 | |
6 | 10 |
7 | 11 |
8 when isMainModule: | 12 when isMainModule: |
9 # print basic driver infos | 13 # print basic driver infos |
10 echo "Layers" | 14 echo "Layers" |
62 var framebuffers: seq[Framebuffer] | 66 var framebuffers: seq[Framebuffer] |
63 for imageview in swapchain.imageviews: | 67 for imageview in swapchain.imageviews: |
64 framebuffers.add device.createFramebuffer(renderpass, [imageview], swapchain.dimension) | 68 framebuffers.add device.createFramebuffer(renderpass, [imageview], swapchain.dimension) |
65 | 69 |
66 # todo: could be create inside "device", but it would be nice to have nim v2 with support for circular dependencies first | 70 # todo: could be create inside "device", but it would be nice to have nim v2 with support for circular dependencies first |
67 var commandPool = device.createCommandPool(family=device.firstGraphicsQueue().get().family, nBuffers=1) | 71 var |
72 commandPool = device.createCommandPool(family=device.firstGraphicsQueue().get().family, nBuffers=1) | |
73 imageAvailable = device.createSemaphore() | |
74 renderFinished = device.createSemaphore() | |
75 inflight = device.createFence() | |
76 | |
77 var vertexshader = device.createVertexShader("#version 450\nvoid main() {}", Vertex()) | |
78 var fragmentshader = device.createFragmentShader("#version 450\nvoid main() {}") | |
79 var pipeline = renderpass.createPipeline(vertexshader, fragmentshader) | |
68 | 80 |
69 echo "All successfull" | 81 echo "All successfull" |
70 echo "Start cleanup" | 82 echo "Start cleanup" |
71 | 83 |
84 # cleanup | |
85 pipeline.destroy() | |
86 vertexshader.destroy() | |
87 fragmentshader.destroy() | |
88 inflight.destroy() | |
89 imageAvailable.destroy() | |
90 renderFinished.destroy() | |
72 commandPool.destroy() | 91 commandPool.destroy() |
73 # cleanup | |
74 for fb in framebuffers.mitems: | 92 for fb in framebuffers.mitems: |
75 fb.destroy() | 93 fb.destroy() |
76 renderpass.destroy() | 94 renderpass.destroy() |
77 swapchain.destroy() | 95 swapchain.destroy() |
78 device.destroy() | 96 device.destroy() |