Mercurial > games > semicongine
comparison semiconginev2/rendering.nim @ 1226:c8e3037aca66 compiletime-tests
add: contrib stuff
| author | sam <sam@basx.dev> |
|---|---|
| date | Wed, 17 Jul 2024 23:41:51 +0700 |
| parents | a3fa15c25026 |
| children | 4e465583ea32 |
comparison
equal
deleted
inserted
replaced
| 1225:27cd1c21290e | 1226:c8e3037aca66 |
|---|---|
| 66 commandBuffers: array[INFLIGHTFRAMES.int, VkCommandBuffer] | 66 commandBuffers: array[INFLIGHTFRAMES.int, VkCommandBuffer] |
| 67 oldSwapchain: ref Swapchain | 67 oldSwapchain: ref Swapchain |
| 68 oldSwapchainCounter: int # swaps until old swapchain will be destroyed | 68 oldSwapchainCounter: int # swaps until old swapchain will be destroyed |
| 69 | 69 |
| 70 var vulkan*: VulkanGlobals | 70 var vulkan*: VulkanGlobals |
| 71 var fullscreen: bool | |
| 71 | 72 |
| 72 func currentFiF*(swapchain: Swapchain): int = swapchain.currentFiF | 73 func currentFiF*(swapchain: Swapchain): int = swapchain.currentFiF |
| 73 | 74 |
| 74 type | 75 type |
| 75 # type aliases | 76 # type aliases |
| 309 proc DestroyVulkan*() = | 310 proc DestroyVulkan*() = |
| 310 vkDestroyDevice(vulkan.device, nil) | 311 vkDestroyDevice(vulkan.device, nil) |
| 311 vkDestroySurfaceKHR(vulkan.instance, vulkan.surface, nil) | 312 vkDestroySurfaceKHR(vulkan.instance, vulkan.surface, nil) |
| 312 vkDestroyDebugUtilsMessengerEXT(vulkan.instance, vulkan.debugMessenger, nil) | 313 vkDestroyDebugUtilsMessengerEXT(vulkan.instance, vulkan.debugMessenger, nil) |
| 313 vkDestroyInstance(vulkan.instance, nil) | 314 vkDestroyInstance(vulkan.instance, nil) |
| 315 | |
| 316 proc ShowSystemCursor*() = vulkan.window.ShowSystemCursor() | |
| 317 proc HideSystemCursor*() = vulkan.window.HideSystemCursor() | |
| 318 proc Fullscreen*(): bool = fullscreen | |
| 319 proc `Fullscreen=`*(enable: bool) = | |
| 320 if enable != fullscreen: | |
| 321 fullscreen = enable | |
| 322 vulkan.window.Fullscreen(fullscreen) | |
| 323 | |
| 324 func GetAspectRatio*(swapchain: Swapchain): float32 = swapchain.width.float32 / swapchain.height.float32 | |
| 325 | |
| 326 proc MaxFramebufferSampleCount*(maxSamples = VK_SAMPLE_COUNT_8_BIT): VkSampleCountFlagBits = | |
| 327 let limits = svkGetPhysicalDeviceProperties().limits | |
| 328 let available = VkSampleCountFlags( | |
| 329 limits.framebufferColorSampleCounts.uint32 and limits.framebufferDepthSampleCounts.uint32 | |
| 330 ).toEnums | |
| 331 return min(max(available), maxSamples) | |
| 332 | |
| 333 | |
| 334 proc `[]`*(texture: Texture, x, y: uint32): auto = | |
| 335 assert x < texture.width, &"{x} < {texture.width} is not true" | |
| 336 assert y < texture.height, &"{y} < {texture.height} is not true" | |
| 337 | |
| 338 texture[].imagedata[y * texture.width + x] | |
| 339 | |
| 340 proc `[]=`*[T](texture: var Texture[T], x, y: uint32, value: T) = | |
| 341 assert x < texture.width | |
| 342 assert y < texture.height | |
| 343 | |
| 344 texture[].imagedata[y * texture.width + x] = value |
