Mercurial > games > semicongine
comparison src/zamikongine/engine.nim @ 24:71bbe11d8de8
did: change shader compilation to run during program compilation, maybe add dynamic version later
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 11 Jan 2023 11:15:02 +0700 |
parents | b45a5d338cd0 |
children | b1b05d4efb52 |
comparison
equal
deleted
inserted
replaced
23:0ffdf1f4ecf4 | 24:71bbe11d8de8 |
---|---|
1 import std/sequtils | |
2 import std/typetraits | 1 import std/typetraits |
3 import std/strformat | 2 import std/strformat |
4 import std/enumerate | 3 import std/enumerate |
5 import std/logging | 4 import std/logging |
6 | 5 |
245 dependencyCount: 1, | 244 dependencyCount: 1, |
246 pDependencies: addr(dependency), | 245 pDependencies: addr(dependency), |
247 ) | 246 ) |
248 checkVkResult device.vkCreateRenderPass(addr(renderPassCreateInfo), nil, addr(result)) | 247 checkVkResult device.vkCreateRenderPass(addr(renderPassCreateInfo), nil, addr(result)) |
249 | 248 |
250 proc setupRenderPipeline[T](device: VkDevice, frameDimension: VkExtent2D, renderPass: VkRenderPass, vertexShader, fragmentShader: string): RenderPipeline = | 249 proc setupRenderPipeline[T](device: VkDevice, frameDimension: VkExtent2D, renderPass: VkRenderPass, vertexShader, fragmentShader: static string): RenderPipeline = |
251 # load shaders | 250 # load shaders |
252 result.shaders.add(device.initShaderProgram(VK_SHADER_STAGE_VERTEX_BIT, vertexShader)) | 251 result.shaders.add(device.initShaderProgram(VK_SHADER_STAGE_VERTEX_BIT, vertexShader)) |
253 result.shaders.add(device.initShaderProgram(VK_SHADER_STAGE_FRAGMENT_BIT, fragmentShader)) | 252 result.shaders.add(device.initShaderProgram(VK_SHADER_STAGE_FRAGMENT_BIT, fragmentShader)) |
254 | 253 |
255 var | 254 var |
487 result.vulkan.renderFinishedSemaphores, | 486 result.vulkan.renderFinishedSemaphores, |
488 result.vulkan.inFlightFences, | 487 result.vulkan.inFlightFences, |
489 ) = result.vulkan.device.device.setupSyncPrimitives() | 488 ) = result.vulkan.device.device.setupSyncPrimitives() |
490 | 489 |
491 | 490 |
492 proc setupPipeline*[T: object, U: uint16|uint32](engine: var Engine, scenedata: ref Thing, vertexShader, fragmentShader: string) = | 491 proc setupPipeline*[T: object, U: uint16|uint32](engine: var Engine, scenedata: ref Thing, vertexShader, fragmentShader: static string) = |
493 engine.currentscenedata = scenedata | 492 engine.currentscenedata = scenedata |
494 engine.vulkan.pipeline = setupRenderPipeline[T]( | 493 engine.vulkan.pipeline = setupRenderPipeline[T]( |
495 engine.vulkan.device.device, | 494 engine.vulkan.device.device, |
496 engine.vulkan.frameDimension, | 495 engine.vulkan.frameDimension, |
497 engine.vulkan.renderPass, | 496 engine.vulkan.renderPass, |