Mercurial > games > semicongine
comparison tests/test_vulkan_wrapper.nim @ 112:0c5a74885796
did: real implementation of buffer and memory, getting closer to collect shit for drawing per pipeline
author | Sam <sam@basx.dev> |
---|---|
date | Sat, 01 Apr 2023 00:40:02 +0700 |
parents | 6fd10b7e2d6a |
children | 7b695fb335ed |
comparison
equal
deleted
inserted
replaced
111:6fd10b7e2d6a | 112:0c5a74885796 |
---|---|
1 import std/os | |
2 import std/options | 1 import std/options |
3 | 2 |
4 import semicongine/vulkan | 3 import semicongine/vulkan |
5 import semicongine/platform/window | 4 import semicongine/platform/window |
6 import semicongine/math | 5 import semicongine/math |
7 import semicongine/entity | 6 import semicongine/entity |
8 import semicongine/scene | 7 import semicongine/scene |
9 import semicongine/gpu_data | 8 import semicongine/gpu_data |
10 | 9 import semicongine/mesh |
11 type | |
12 Vertex = object | |
13 pos: Vec3 | |
14 FragmentInput = object | |
15 fragpos: Vec3 | |
16 Uniforms = object | |
17 time: float32 | |
18 Pixel = object | |
19 color: Vec4 | |
20 | 10 |
21 proc diagnostics(instance: Instance) = | 11 proc diagnostics(instance: Instance) = |
22 # diagnostic output | 12 # diagnostic output |
23 echo "Devices" | 13 echo "Devices" |
24 for device in instance.getPhysicalDevices(): | 14 for device in instance.getPhysicalDevices(): |
81 renderPass = device.simpleForwardRenderPass(surfaceFormat.format, vertexshader, fragmentshader, 2) | 71 renderPass = device.simpleForwardRenderPass(surfaceFormat.format, vertexshader, fragmentshader, 2) |
82 var (swapchain, res) = device.createSwapchain(renderPass, surfaceFormat, device.firstGraphicsQueue().get().family, 2) | 72 var (swapchain, res) = device.createSwapchain(renderPass, surfaceFormat, device.firstGraphicsQueue().get().family, 2) |
83 if res != VK_SUCCESS: | 73 if res != VK_SUCCESS: |
84 raise newException(Exception, "Unable to create swapchain") | 74 raise newException(Exception, "Unable to create swapchain") |
85 | 75 |
86 var thescene = Scene(root: newEntity("scene")) | 76 var thescene = Scene(name: "main", root: newEntity("triangle", newMesh([newVec3(-1, -1), newVec3(0, 1), newVec3(1, -1)]))) |
87 thescene.setupDrawables(renderPass) | 77 thescene.setupDrawables(renderPass) |
88 | 78 |
89 echo "Setup successfull, start rendering" | 79 echo "Setup successfull, start rendering" |
90 for i in 0 ..< 10: | 80 for i in 0 ..< 1: |
91 discard swapchain.drawScene(thescene) | 81 discard swapchain.drawScene(thescene) |
92 echo "Rendered ", swapchain.framesRendered, " frames" | 82 echo "Rendered ", swapchain.framesRendered, " frames" |
93 echo "Start cleanup" | 83 echo "Start cleanup" |
94 | 84 |
95 | 85 |