# HG changeset patch # User sam # Date 1717833505 -25200 # Node ID 114f395b91449918775e3fd502f7263ad1d67ec1 # Parent 02e1d2658ff54b8e5c25aa2ba46838591898d034 did: finish refactoring and updated all tests accordingly diff -r 02e1d2658ff5 -r 114f395b9144 examples/E01_hello_triangle.nim --- a/examples/E01_hello_triangle.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/examples/E01_hello_triangle.nim Sat Jun 08 14:58:25 2024 +0700 @@ -22,7 +22,7 @@ meshes: @[newMesh( positions = [NewVec3f(-0.5, 0.5), NewVec3f(0, -0.5), NewVec3f(0.5, 0.5)], colors = [NewVec4f(1, 0, 0, 1), NewVec4f(0, 1, 0, 1), NewVec4f(0, 0, 1, 1)], - material = VERTEX_COLORED_MATERIAL.initMaterialData() + material = VERTEX_COLORED_MATERIAL.InitMaterialData() )] ) myengine = initEngine("Hello triangle", showFps = true) diff -r 02e1d2658ff5 -r 114f395b9144 examples/E02_squares.nim --- a/examples/E02_squares.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/examples/E02_squares.nim Sat Jun 08 14:58:25 2024 +0700 @@ -74,7 +74,7 @@ colors = colors, ) squaremesh[].initVertexAttribute("index", iValues.toSeq) - squaremesh.material = matDef.initMaterialData(name = "default") + squaremesh.material = matDef.InitMaterialData(name = "default") var myengine = initEngine("Squares") myengine.initRenderer({matDef: shaderConfiguration}) diff -r 02e1d2658ff5 -r 114f395b9144 examples/E03_hello_cube.nim --- a/examples/E03_hello_cube.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/examples/E03_hello_cube.nim Sat Jun 08 14:58:25 2024 +0700 @@ -60,7 +60,7 @@ fragmentCode = "color = outcolor;", ) var matDef = MaterialType(name: "default material", vertexAttributes: {"position": Vec3F32, "color": Vec4F32}.toTable) - var cube = Scene(name: "scene", meshes: @[newMesh(positions = cube_pos, indices = tris, colors = cube_color, material = matDef.initMaterialData(name = "default"))]) + var cube = Scene(name: "scene", meshes: @[newMesh(positions = cube_pos, indices = tris, colors = cube_color, material = matDef.InitMaterialData(name = "default"))]) cube.addShaderGlobal("projection", Unit4f32) cube.addShaderGlobal("view", Unit4f32) cube.addShaderGlobal("model", Unit4f32) diff -r 02e1d2658ff5 -r 114f395b9144 examples/E04_input.nim --- a/examples/E04_input.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/examples/E04_input.nim Sat Jun 08 14:58:25 2024 +0700 @@ -115,13 +115,13 @@ cursormesh = newMesh( positions = positions, colors = arrow_colors, - material = matDef.initMaterialData(), + material = matDef.InitMaterialData(), ) keyboardmesh = newMesh( positions = keyvertexpos, colors = keyvertexcolor, indices = keymeshindices, - material = matDef.initMaterialData(), + material = matDef.InitMaterialData(), ) backgroundmesh = newMesh( positions = @[ @@ -137,7 +137,7 @@ backgroundColor, ], indices = @[[0'u16, 1'u16, 2'u16], [2'u16, 3'u16, 0'u16]], - material = matDef.initMaterialData(), + material = matDef.InitMaterialData(), ) # define mesh objects diff -r 02e1d2658ff5 -r 114f395b9144 examples/E10_pong.nim --- a/examples/E10_pong.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/examples/E10_pong.nim Sat Jun 08 14:58:25 2024 +0700 @@ -23,9 +23,9 @@ var myengine = initEngine("Pong") var player = rect(color = barcolor, width = barWidth, height = barSize) - player.material = matDef.initMaterialData(name = "player material") + player.material = matDef.InitMaterialData(name = "player material") var ball = circle(color = ballcolor) - ball.material = matDef.initMaterialData(name = "player material") + ball.material = matDef.InitMaterialData(name = "player material") level = Scene(name: "scene", meshes: @[ball, player]) const diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/audio.nim --- a/semicongine/audio.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/audio.nim Sat Jun 08 14:58:25 2024 +0700 @@ -62,7 +62,7 @@ proc LoadSound*(mixer: var Mixer, name: string, resource: string) = assert not (name in mixer.sounds) - mixer.sounds[name] = loadAudio(resource) + mixer.sounds[name] = LoadAudio(resource) proc AddSound*(mixer: var Mixer, name: string, sound: Sound) = assert not (name in mixer.sounds) diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/core/matrix.nim --- a/semicongine/core/matrix.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/core/matrix.nim Sat Jun 08 14:58:25 2024 +0700 @@ -118,7 +118,7 @@ maxwidth = 0 for n in value.data: - let strval = &"{n:.4f}" + let strval = &"{float(n):.4f}" strvalues.add(strval) if strval.len > maxwidth: maxwidth = strval.len diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/core/vulkanapi.nim --- a/semicongine/core/vulkanapi.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/core/vulkanapi.nim Sat Jun 08 14:58:25 2024 +0700 @@ -135,196 +135,196 @@ VkSemaphoreSciSyncPoolNV* = distinct VkNonDispatchableHandle VkRemoteAddressNV* = pointer proc `$`*(handle: VkInstance): string = "VkInstance(" & $(uint(handle)) & ")" -proc valid*(handle: VkInstance): bool = uint(handle) != 0 -proc reset*(handle: var VkInstance) = handle = VkInstance(0) +proc Valid*(handle: VkInstance): bool = uint(handle) != 0 +proc Reset*(handle: var VkInstance) = handle = VkInstance(0) proc `==`*(a, b: VkInstance): bool = uint(a) == uint(b) proc `$`*(handle: VkPhysicalDevice): string = "VkPhysicalDevice(" & $(uint(handle)) & ")" -proc valid*(handle: VkPhysicalDevice): bool = uint(handle) != 0 -proc reset*(handle: var VkPhysicalDevice) = handle = VkPhysicalDevice(0) +proc Valid*(handle: VkPhysicalDevice): bool = uint(handle) != 0 +proc Reset*(handle: var VkPhysicalDevice) = handle = VkPhysicalDevice(0) proc `==`*(a, b: VkPhysicalDevice): bool = uint(a) == uint(b) proc `$`*(handle: VkDevice): string = "VkDevice(" & $(uint(handle)) & ")" -proc valid*(handle: VkDevice): bool = uint(handle) != 0 -proc reset*(handle: var VkDevice) = handle = VkDevice(0) +proc Valid*(handle: VkDevice): bool = uint(handle) != 0 +proc Reset*(handle: var VkDevice) = handle = VkDevice(0) proc `==`*(a, b: VkDevice): bool = uint(a) == uint(b) proc `$`*(handle: VkQueue): string = "VkQueue(" & $(uint(handle)) & ")" -proc valid*(handle: VkQueue): bool = uint(handle) != 0 -proc reset*(handle: var VkQueue) = handle = VkQueue(0) +proc Valid*(handle: VkQueue): bool = uint(handle) != 0 +proc Reset*(handle: var VkQueue) = handle = VkQueue(0) proc `==`*(a, b: VkQueue): bool = uint(a) == uint(b) proc `$`*(handle: VkCommandBuffer): string = "VkCommandBuffer(" & $(uint(handle)) & ")" -proc valid*(handle: VkCommandBuffer): bool = uint(handle) != 0 -proc reset*(handle: var VkCommandBuffer) = handle = VkCommandBuffer(0) +proc Valid*(handle: VkCommandBuffer): bool = uint(handle) != 0 +proc Reset*(handle: var VkCommandBuffer) = handle = VkCommandBuffer(0) proc `==`*(a, b: VkCommandBuffer): bool = uint(a) == uint(b) proc `$`*(handle: VkDeviceMemory): string = "VkDeviceMemory(" & $(uint(handle)) & ")" -proc valid*(handle: VkDeviceMemory): bool = uint(handle) != 0 -proc reset*(handle: var VkDeviceMemory) = handle = VkDeviceMemory(0) +proc Valid*(handle: VkDeviceMemory): bool = uint(handle) != 0 +proc Reset*(handle: var VkDeviceMemory) = handle = VkDeviceMemory(0) proc `==`*(a, b: VkDeviceMemory): bool = uint(a) == uint(b) proc `$`*(handle: VkCommandPool): string = "VkCommandPool(" & $(uint(handle)) & ")" -proc valid*(handle: VkCommandPool): bool = uint(handle) != 0 -proc reset*(handle: var VkCommandPool) = handle = VkCommandPool(0) +proc Valid*(handle: VkCommandPool): bool = uint(handle) != 0 +proc Reset*(handle: var VkCommandPool) = handle = VkCommandPool(0) proc `==`*(a, b: VkCommandPool): bool = uint(a) == uint(b) proc `$`*(handle: VkBuffer): string = "VkBuffer(" & $(uint(handle)) & ")" -proc valid*(handle: VkBuffer): bool = uint(handle) != 0 -proc reset*(handle: var VkBuffer) = handle = VkBuffer(0) +proc Valid*(handle: VkBuffer): bool = uint(handle) != 0 +proc Reset*(handle: var VkBuffer) = handle = VkBuffer(0) proc `==`*(a, b: VkBuffer): bool = uint(a) == uint(b) proc `$`*(handle: VkBufferView): string = "VkBufferView(" & $(uint(handle)) & ")" -proc valid*(handle: VkBufferView): bool = uint(handle) != 0 -proc reset*(handle: var VkBufferView) = handle = VkBufferView(0) +proc Valid*(handle: VkBufferView): bool = uint(handle) != 0 +proc Reset*(handle: var VkBufferView) = handle = VkBufferView(0) proc `==`*(a, b: VkBufferView): bool = uint(a) == uint(b) proc `$`*(handle: VkImage): string = "VkImage(" & $(uint(handle)) & ")" -proc valid*(handle: VkImage): bool = uint(handle) != 0 -proc reset*(handle: var VkImage) = handle = VkImage(0) +proc Valid*(handle: VkImage): bool = uint(handle) != 0 +proc Reset*(handle: var VkImage) = handle = VkImage(0) proc `==`*(a, b: VkImage): bool = uint(a) == uint(b) proc `$`*(handle: VkImageView): string = "VkImageView(" & $(uint(handle)) & ")" -proc valid*(handle: VkImageView): bool = uint(handle) != 0 -proc reset*(handle: var VkImageView) = handle = VkImageView(0) +proc Valid*(handle: VkImageView): bool = uint(handle) != 0 +proc Reset*(handle: var VkImageView) = handle = VkImageView(0) proc `==`*(a, b: VkImageView): bool = uint(a) == uint(b) proc `$`*(handle: VkShaderModule): string = "VkShaderModule(" & $(uint(handle)) & ")" -proc valid*(handle: VkShaderModule): bool = uint(handle) != 0 -proc reset*(handle: var VkShaderModule) = handle = VkShaderModule(0) +proc Valid*(handle: VkShaderModule): bool = uint(handle) != 0 +proc Reset*(handle: var VkShaderModule) = handle = VkShaderModule(0) proc `==`*(a, b: VkShaderModule): bool = uint(a) == uint(b) proc `$`*(handle: VkPipeline): string = "VkPipeline(" & $(uint(handle)) & ")" -proc valid*(handle: VkPipeline): bool = uint(handle) != 0 -proc reset*(handle: var VkPipeline) = handle = VkPipeline(0) +proc Valid*(handle: VkPipeline): bool = uint(handle) != 0 +proc Reset*(handle: var VkPipeline) = handle = VkPipeline(0) proc `==`*(a, b: VkPipeline): bool = uint(a) == uint(b) proc `$`*(handle: VkPipelineLayout): string = "VkPipelineLayout(" & $(uint(handle)) & ")" -proc valid*(handle: VkPipelineLayout): bool = uint(handle) != 0 -proc reset*(handle: var VkPipelineLayout) = handle = VkPipelineLayout(0) +proc Valid*(handle: VkPipelineLayout): bool = uint(handle) != 0 +proc Reset*(handle: var VkPipelineLayout) = handle = VkPipelineLayout(0) proc `==`*(a, b: VkPipelineLayout): bool = uint(a) == uint(b) proc `$`*(handle: VkSampler): string = "VkSampler(" & $(uint(handle)) & ")" -proc valid*(handle: VkSampler): bool = uint(handle) != 0 -proc reset*(handle: var VkSampler) = handle = VkSampler(0) +proc Valid*(handle: VkSampler): bool = uint(handle) != 0 +proc Reset*(handle: var VkSampler) = handle = VkSampler(0) proc `==`*(a, b: VkSampler): bool = uint(a) == uint(b) proc `$`*(handle: VkDescriptorSet): string = "VkDescriptorSet(" & $(uint(handle)) & ")" -proc valid*(handle: VkDescriptorSet): bool = uint(handle) != 0 -proc reset*(handle: var VkDescriptorSet) = handle = VkDescriptorSet(0) +proc Valid*(handle: VkDescriptorSet): bool = uint(handle) != 0 +proc Reset*(handle: var VkDescriptorSet) = handle = VkDescriptorSet(0) proc `==`*(a, b: VkDescriptorSet): bool = uint(a) == uint(b) proc `$`*(handle: VkDescriptorSetLayout): string = "VkDescriptorSetLayout(" & $(uint(handle)) & ")" -proc valid*(handle: VkDescriptorSetLayout): bool = uint(handle) != 0 -proc reset*(handle: var VkDescriptorSetLayout) = handle = VkDescriptorSetLayout(0) +proc Valid*(handle: VkDescriptorSetLayout): bool = uint(handle) != 0 +proc Reset*(handle: var VkDescriptorSetLayout) = handle = VkDescriptorSetLayout(0) proc `==`*(a, b: VkDescriptorSetLayout): bool = uint(a) == uint(b) proc `$`*(handle: VkDescriptorPool): string = "VkDescriptorPool(" & $(uint(handle)) & ")" -proc valid*(handle: VkDescriptorPool): bool = uint(handle) != 0 -proc reset*(handle: var VkDescriptorPool) = handle = VkDescriptorPool(0) +proc Valid*(handle: VkDescriptorPool): bool = uint(handle) != 0 +proc Reset*(handle: var VkDescriptorPool) = handle = VkDescriptorPool(0) proc `==`*(a, b: VkDescriptorPool): bool = uint(a) == uint(b) proc `$`*(handle: VkFence): string = "VkFence(" & $(uint(handle)) & ")" -proc valid*(handle: VkFence): bool = uint(handle) != 0 -proc reset*(handle: var VkFence) = handle = VkFence(0) +proc Valid*(handle: VkFence): bool = uint(handle) != 0 +proc Reset*(handle: var VkFence) = handle = VkFence(0) proc `==`*(a, b: VkFence): bool = uint(a) == uint(b) proc `$`*(handle: VkSemaphore): string = "VkSemaphore(" & $(uint(handle)) & ")" -proc valid*(handle: VkSemaphore): bool = uint(handle) != 0 -proc reset*(handle: var VkSemaphore) = handle = VkSemaphore(0) +proc Valid*(handle: VkSemaphore): bool = uint(handle) != 0 +proc Reset*(handle: var VkSemaphore) = handle = VkSemaphore(0) proc `==`*(a, b: VkSemaphore): bool = uint(a) == uint(b) proc `$`*(handle: VkEvent): string = "VkEvent(" & $(uint(handle)) & ")" -proc valid*(handle: VkEvent): bool = uint(handle) != 0 -proc reset*(handle: var VkEvent) = handle = VkEvent(0) +proc Valid*(handle: VkEvent): bool = uint(handle) != 0 +proc Reset*(handle: var VkEvent) = handle = VkEvent(0) proc `==`*(a, b: VkEvent): bool = uint(a) == uint(b) proc `$`*(handle: VkQueryPool): string = "VkQueryPool(" & $(uint(handle)) & ")" -proc valid*(handle: VkQueryPool): bool = uint(handle) != 0 -proc reset*(handle: var VkQueryPool) = handle = VkQueryPool(0) +proc Valid*(handle: VkQueryPool): bool = uint(handle) != 0 +proc Reset*(handle: var VkQueryPool) = handle = VkQueryPool(0) proc `==`*(a, b: VkQueryPool): bool = uint(a) == uint(b) proc `$`*(handle: VkFramebuffer): string = "VkFramebuffer(" & $(uint(handle)) & ")" -proc valid*(handle: VkFramebuffer): bool = uint(handle) != 0 -proc reset*(handle: var VkFramebuffer) = handle = VkFramebuffer(0) +proc Valid*(handle: VkFramebuffer): bool = uint(handle) != 0 +proc Reset*(handle: var VkFramebuffer) = handle = VkFramebuffer(0) proc `==`*(a, b: VkFramebuffer): bool = uint(a) == uint(b) proc `$`*(handle: VkRenderPass): string = "VkRenderPass(" & $(uint(handle)) & ")" -proc valid*(handle: VkRenderPass): bool = uint(handle) != 0 -proc reset*(handle: var VkRenderPass) = handle = VkRenderPass(0) +proc Valid*(handle: VkRenderPass): bool = uint(handle) != 0 +proc Reset*(handle: var VkRenderPass) = handle = VkRenderPass(0) proc `==`*(a, b: VkRenderPass): bool = uint(a) == uint(b) proc `$`*(handle: VkPipelineCache): string = "VkPipelineCache(" & $(uint(handle)) & ")" -proc valid*(handle: VkPipelineCache): bool = uint(handle) != 0 -proc reset*(handle: var VkPipelineCache) = handle = VkPipelineCache(0) +proc Valid*(handle: VkPipelineCache): bool = uint(handle) != 0 +proc Reset*(handle: var VkPipelineCache) = handle = VkPipelineCache(0) proc `==`*(a, b: VkPipelineCache): bool = uint(a) == uint(b) proc `$`*(handle: VkIndirectCommandsLayoutNV): string = "VkIndirectCommandsLayoutNV(" & $(uint(handle)) & ")" -proc valid*(handle: VkIndirectCommandsLayoutNV): bool = uint(handle) != 0 -proc reset*(handle: var VkIndirectCommandsLayoutNV) = handle = VkIndirectCommandsLayoutNV(0) +proc Valid*(handle: VkIndirectCommandsLayoutNV): bool = uint(handle) != 0 +proc Reset*(handle: var VkIndirectCommandsLayoutNV) = handle = VkIndirectCommandsLayoutNV(0) proc `==`*(a, b: VkIndirectCommandsLayoutNV): bool = uint(a) == uint(b) proc `$`*(handle: VkDescriptorUpdateTemplate): string = "VkDescriptorUpdateTemplate(" & $(uint(handle)) & ")" -proc valid*(handle: VkDescriptorUpdateTemplate): bool = uint(handle) != 0 -proc reset*(handle: var VkDescriptorUpdateTemplate) = handle = VkDescriptorUpdateTemplate(0) +proc Valid*(handle: VkDescriptorUpdateTemplate): bool = uint(handle) != 0 +proc Reset*(handle: var VkDescriptorUpdateTemplate) = handle = VkDescriptorUpdateTemplate(0) proc `==`*(a, b: VkDescriptorUpdateTemplate): bool = uint(a) == uint(b) proc `$`*(handle: VkSamplerYcbcrConversion): string = "VkSamplerYcbcrConversion(" & $(uint(handle)) & ")" -proc valid*(handle: VkSamplerYcbcrConversion): bool = uint(handle) != 0 -proc reset*(handle: var VkSamplerYcbcrConversion) = handle = VkSamplerYcbcrConversion(0) +proc Valid*(handle: VkSamplerYcbcrConversion): bool = uint(handle) != 0 +proc Reset*(handle: var VkSamplerYcbcrConversion) = handle = VkSamplerYcbcrConversion(0) proc `==`*(a, b: VkSamplerYcbcrConversion): bool = uint(a) == uint(b) proc `$`*(handle: VkValidationCacheEXT): string = "VkValidationCacheEXT(" & $(uint(handle)) & ")" -proc valid*(handle: VkValidationCacheEXT): bool = uint(handle) != 0 -proc reset*(handle: var VkValidationCacheEXT) = handle = VkValidationCacheEXT(0) +proc Valid*(handle: VkValidationCacheEXT): bool = uint(handle) != 0 +proc Reset*(handle: var VkValidationCacheEXT) = handle = VkValidationCacheEXT(0) proc `==`*(a, b: VkValidationCacheEXT): bool = uint(a) == uint(b) proc `$`*(handle: VkAccelerationStructureKHR): string = "VkAccelerationStructureKHR(" & $(uint(handle)) & ")" -proc valid*(handle: VkAccelerationStructureKHR): bool = uint(handle) != 0 -proc reset*(handle: var VkAccelerationStructureKHR) = handle = VkAccelerationStructureKHR(0) +proc Valid*(handle: VkAccelerationStructureKHR): bool = uint(handle) != 0 +proc Reset*(handle: var VkAccelerationStructureKHR) = handle = VkAccelerationStructureKHR(0) proc `==`*(a, b: VkAccelerationStructureKHR): bool = uint(a) == uint(b) proc `$`*(handle: VkAccelerationStructureNV): string = "VkAccelerationStructureNV(" & $(uint(handle)) & ")" -proc valid*(handle: VkAccelerationStructureNV): bool = uint(handle) != 0 -proc reset*(handle: var VkAccelerationStructureNV) = handle = VkAccelerationStructureNV(0) +proc Valid*(handle: VkAccelerationStructureNV): bool = uint(handle) != 0 +proc Reset*(handle: var VkAccelerationStructureNV) = handle = VkAccelerationStructureNV(0) proc `==`*(a, b: VkAccelerationStructureNV): bool = uint(a) == uint(b) proc `$`*(handle: VkPerformanceConfigurationINTEL): string = "VkPerformanceConfigurationINTEL(" & $(uint(handle)) & ")" -proc valid*(handle: VkPerformanceConfigurationINTEL): bool = uint(handle) != 0 -proc reset*(handle: var VkPerformanceConfigurationINTEL) = handle = VkPerformanceConfigurationINTEL(0) +proc Valid*(handle: VkPerformanceConfigurationINTEL): bool = uint(handle) != 0 +proc Reset*(handle: var VkPerformanceConfigurationINTEL) = handle = VkPerformanceConfigurationINTEL(0) proc `==`*(a, b: VkPerformanceConfigurationINTEL): bool = uint(a) == uint(b) proc `$`*(handle: VkBufferCollectionFUCHSIA): string = "VkBufferCollectionFUCHSIA(" & $(uint(handle)) & ")" -proc valid*(handle: VkBufferCollectionFUCHSIA): bool = uint(handle) != 0 -proc reset*(handle: var VkBufferCollectionFUCHSIA) = handle = VkBufferCollectionFUCHSIA(0) +proc Valid*(handle: VkBufferCollectionFUCHSIA): bool = uint(handle) != 0 +proc Reset*(handle: var VkBufferCollectionFUCHSIA) = handle = VkBufferCollectionFUCHSIA(0) proc `==`*(a, b: VkBufferCollectionFUCHSIA): bool = uint(a) == uint(b) proc `$`*(handle: VkDeferredOperationKHR): string = "VkDeferredOperationKHR(" & $(uint(handle)) & ")" -proc valid*(handle: VkDeferredOperationKHR): bool = uint(handle) != 0 -proc reset*(handle: var VkDeferredOperationKHR) = handle = VkDeferredOperationKHR(0) +proc Valid*(handle: VkDeferredOperationKHR): bool = uint(handle) != 0 +proc Reset*(handle: var VkDeferredOperationKHR) = handle = VkDeferredOperationKHR(0) proc `==`*(a, b: VkDeferredOperationKHR): bool = uint(a) == uint(b) proc `$`*(handle: VkPrivateDataSlot): string = "VkPrivateDataSlot(" & $(uint(handle)) & ")" -proc valid*(handle: VkPrivateDataSlot): bool = uint(handle) != 0 -proc reset*(handle: var VkPrivateDataSlot) = handle = VkPrivateDataSlot(0) +proc Valid*(handle: VkPrivateDataSlot): bool = uint(handle) != 0 +proc Reset*(handle: var VkPrivateDataSlot) = handle = VkPrivateDataSlot(0) proc `==`*(a, b: VkPrivateDataSlot): bool = uint(a) == uint(b) proc `$`*(handle: VkCuModuleNVX): string = "VkCuModuleNVX(" & $(uint(handle)) & ")" -proc valid*(handle: VkCuModuleNVX): bool = uint(handle) != 0 -proc reset*(handle: var VkCuModuleNVX) = handle = VkCuModuleNVX(0) +proc Valid*(handle: VkCuModuleNVX): bool = uint(handle) != 0 +proc Reset*(handle: var VkCuModuleNVX) = handle = VkCuModuleNVX(0) proc `==`*(a, b: VkCuModuleNVX): bool = uint(a) == uint(b) proc `$`*(handle: VkCuFunctionNVX): string = "VkCuFunctionNVX(" & $(uint(handle)) & ")" -proc valid*(handle: VkCuFunctionNVX): bool = uint(handle) != 0 -proc reset*(handle: var VkCuFunctionNVX) = handle = VkCuFunctionNVX(0) +proc Valid*(handle: VkCuFunctionNVX): bool = uint(handle) != 0 +proc Reset*(handle: var VkCuFunctionNVX) = handle = VkCuFunctionNVX(0) proc `==`*(a, b: VkCuFunctionNVX): bool = uint(a) == uint(b) proc `$`*(handle: VkOpticalFlowSessionNV): string = "VkOpticalFlowSessionNV(" & $(uint(handle)) & ")" -proc valid*(handle: VkOpticalFlowSessionNV): bool = uint(handle) != 0 -proc reset*(handle: var VkOpticalFlowSessionNV) = handle = VkOpticalFlowSessionNV(0) +proc Valid*(handle: VkOpticalFlowSessionNV): bool = uint(handle) != 0 +proc Reset*(handle: var VkOpticalFlowSessionNV) = handle = VkOpticalFlowSessionNV(0) proc `==`*(a, b: VkOpticalFlowSessionNV): bool = uint(a) == uint(b) proc `$`*(handle: VkMicromapEXT): string = "VkMicromapEXT(" & $(uint(handle)) & ")" -proc valid*(handle: VkMicromapEXT): bool = uint(handle) != 0 -proc reset*(handle: var VkMicromapEXT) = handle = VkMicromapEXT(0) +proc Valid*(handle: VkMicromapEXT): bool = uint(handle) != 0 +proc Reset*(handle: var VkMicromapEXT) = handle = VkMicromapEXT(0) proc `==`*(a, b: VkMicromapEXT): bool = uint(a) == uint(b) proc `$`*(handle: VkDisplayKHR): string = "VkDisplayKHR(" & $(uint(handle)) & ")" -proc valid*(handle: VkDisplayKHR): bool = uint(handle) != 0 -proc reset*(handle: var VkDisplayKHR) = handle = VkDisplayKHR(0) +proc Valid*(handle: VkDisplayKHR): bool = uint(handle) != 0 +proc Reset*(handle: var VkDisplayKHR) = handle = VkDisplayKHR(0) proc `==`*(a, b: VkDisplayKHR): bool = uint(a) == uint(b) proc `$`*(handle: VkDisplayModeKHR): string = "VkDisplayModeKHR(" & $(uint(handle)) & ")" -proc valid*(handle: VkDisplayModeKHR): bool = uint(handle) != 0 -proc reset*(handle: var VkDisplayModeKHR) = handle = VkDisplayModeKHR(0) +proc Valid*(handle: VkDisplayModeKHR): bool = uint(handle) != 0 +proc Reset*(handle: var VkDisplayModeKHR) = handle = VkDisplayModeKHR(0) proc `==`*(a, b: VkDisplayModeKHR): bool = uint(a) == uint(b) proc `$`*(handle: VkSurfaceKHR): string = "VkSurfaceKHR(" & $(uint(handle)) & ")" -proc valid*(handle: VkSurfaceKHR): bool = uint(handle) != 0 -proc reset*(handle: var VkSurfaceKHR) = handle = VkSurfaceKHR(0) +proc Valid*(handle: VkSurfaceKHR): bool = uint(handle) != 0 +proc Reset*(handle: var VkSurfaceKHR) = handle = VkSurfaceKHR(0) proc `==`*(a, b: VkSurfaceKHR): bool = uint(a) == uint(b) proc `$`*(handle: VkSwapchainKHR): string = "VkSwapchainKHR(" & $(uint(handle)) & ")" -proc valid*(handle: VkSwapchainKHR): bool = uint(handle) != 0 -proc reset*(handle: var VkSwapchainKHR) = handle = VkSwapchainKHR(0) +proc Valid*(handle: VkSwapchainKHR): bool = uint(handle) != 0 +proc Reset*(handle: var VkSwapchainKHR) = handle = VkSwapchainKHR(0) proc `==`*(a, b: VkSwapchainKHR): bool = uint(a) == uint(b) proc `$`*(handle: VkDebugReportCallbackEXT): string = "VkDebugReportCallbackEXT(" & $(uint(handle)) & ")" -proc valid*(handle: VkDebugReportCallbackEXT): bool = uint(handle) != 0 -proc reset*(handle: var VkDebugReportCallbackEXT) = handle = VkDebugReportCallbackEXT(0) +proc Valid*(handle: VkDebugReportCallbackEXT): bool = uint(handle) != 0 +proc Reset*(handle: var VkDebugReportCallbackEXT) = handle = VkDebugReportCallbackEXT(0) proc `==`*(a, b: VkDebugReportCallbackEXT): bool = uint(a) == uint(b) proc `$`*(handle: VkDebugUtilsMessengerEXT): string = "VkDebugUtilsMessengerEXT(" & $(uint(handle)) & ")" -proc valid*(handle: VkDebugUtilsMessengerEXT): bool = uint(handle) != 0 -proc reset*(handle: var VkDebugUtilsMessengerEXT) = handle = VkDebugUtilsMessengerEXT(0) +proc Valid*(handle: VkDebugUtilsMessengerEXT): bool = uint(handle) != 0 +proc Reset*(handle: var VkDebugUtilsMessengerEXT) = handle = VkDebugUtilsMessengerEXT(0) proc `==`*(a, b: VkDebugUtilsMessengerEXT): bool = uint(a) == uint(b) proc `$`*(handle: VkVideoSessionKHR): string = "VkVideoSessionKHR(" & $(uint(handle)) & ")" -proc valid*(handle: VkVideoSessionKHR): bool = uint(handle) != 0 -proc reset*(handle: var VkVideoSessionKHR) = handle = VkVideoSessionKHR(0) +proc Valid*(handle: VkVideoSessionKHR): bool = uint(handle) != 0 +proc Reset*(handle: var VkVideoSessionKHR) = handle = VkVideoSessionKHR(0) proc `==`*(a, b: VkVideoSessionKHR): bool = uint(a) == uint(b) proc `$`*(handle: VkVideoSessionParametersKHR): string = "VkVideoSessionParametersKHR(" & $(uint(handle)) & ")" -proc valid*(handle: VkVideoSessionParametersKHR): bool = uint(handle) != 0 -proc reset*(handle: var VkVideoSessionParametersKHR) = handle = VkVideoSessionParametersKHR(0) +proc Valid*(handle: VkVideoSessionParametersKHR): bool = uint(handle) != 0 +proc Reset*(handle: var VkVideoSessionParametersKHR) = handle = VkVideoSessionParametersKHR(0) proc `==`*(a, b: VkVideoSessionParametersKHR): bool = uint(a) == uint(b) proc `$`*(handle: VkSemaphoreSciSyncPoolNV): string = "VkSemaphoreSciSyncPoolNV(" & $(uint(handle)) & ")" -proc valid*(handle: VkSemaphoreSciSyncPoolNV): bool = uint(handle) != 0 -proc reset*(handle: var VkSemaphoreSciSyncPoolNV) = handle = VkSemaphoreSciSyncPoolNV(0) +proc Valid*(handle: VkSemaphoreSciSyncPoolNV): bool = uint(handle) != 0 +proc Reset*(handle: var VkSemaphoreSciSyncPoolNV) = handle = VkSemaphoreSciSyncPoolNV(0) proc `==`*(a, b: VkSemaphoreSciSyncPoolNV): bool = uint(a) == uint(b) type VkFramebufferCreateFlags* = distinct VkFlags diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/engine.nim --- a/semicongine/engine.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/engine.nim Sat Jun 08 14:58:25 2024 +0700 @@ -50,12 +50,12 @@ proc Destroy*(engine: var Engine) = checkVkResult engine.device.vk.vkDeviceWaitIdle() if engine.renderer.isSome: - engine.renderer.get.destroy() - engine.device.destroy() - if engine.debugger.messenger.valid: - engine.debugger.destroy() - engine.window.destroy() - engine.instance.destroy() + engine.renderer.get.Destroy() + engine.device.Destroy() + if engine.debugger.messenger.Valid: + engine.debugger.Destroy() + engine.window.Destroy() + engine.instance.Destroy() if SteamAvailable(): SteamShutdown() @@ -77,7 +77,7 @@ result.applicationName = applicationName result.showFps = showFps - result.window = createWindow(result.applicationName) + result.window = CreateWindow(result.applicationName) var layers = @vulkanLayers @@ -91,19 +91,19 @@ # putEnv("VK_LAYER_ENABLES", "VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT") putEnv("VK_LAYER_ENABLES", "VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_AMD,VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_NVIDIA,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXTVK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT") - result.instance = result.window.createInstance( + result.instance = result.window.CreateInstance( vulkanVersion = vulkanVersion, instanceExtensions = instanceExtensions, layers = layers.deduplicate(), ) if DEBUG: - result.debugger = result.instance.createDebugMessenger() + result.debugger = result.instance.CreateDebugMessenger() # create devices - let selectedPhysicalDevice = result.instance.getPhysicalDevices().filterBestGraphics() - result.device = result.instance.createDevice( + let selectedPhysicalDevice = result.instance.GetPhysicalDevices().FilterBestGraphics() + result.device = result.instance.CreateDevice( selectedPhysicalDevice, enabledExtensions = @[], - selectedPhysicalDevice.filterForGraphicsPresentationQueues() + selectedPhysicalDevice.FilterForGraphicsPresentationQueues() ) StartMixerThread() @@ -142,27 +142,27 @@ assert engine.renderer.isSome assert not scene.loaded checkVkResult engine.device.vk.vkDeviceWaitIdle() - scene.addShaderGlobal(ASPECT_RATIO_ATTRIBUTE, engine.GetAspectRatio) - engine.renderer.get.setupDrawableBuffers(scene) - engine.renderer.get.updateMeshData(scene, forceAll = true) - engine.renderer.get.updateUniformData(scene, forceAll = true) + scene.AddShaderGlobal(ASPECT_RATIO_ATTRIBUTE, engine.GetAspectRatio) + engine.renderer.get.SetupDrawableBuffers(scene) + engine.renderer.get.UpdateMeshData(scene, forceAll = true) + engine.renderer.get.UpdateUniformData(scene, forceAll = true) checkVkResult engine.device.vk.vkDeviceWaitIdle() debug &"done loading scene '{scene.name}'" proc UnLoadScene*(engine: var Engine, scene: Scene) = debug &"unload scene '{scene.name}'" - engine.renderer.get.destroy(scene) + engine.renderer.get.Destroy(scene) proc RenderScene*(engine: var Engine, scene: var Scene) = assert engine.renderer.isSome, "Renderer has not yet been initialized, call 'engine.InitRenderer' first" - assert engine.renderer.get.hasScene(scene), &"Scene '{scene.name}' has not been loaded yet" + assert engine.renderer.get.HasScene(scene), &"Scene '{scene.name}' has not been loaded yet" let t0 = getMonoTime() - engine.renderer.get.startNewFrame() - scene.setShaderGlobal(ASPECT_RATIO_ATTRIBUTE, engine.GetAspectRatio) - engine.renderer.get.updateMeshData(scene) - engine.renderer.get.updateUniformData(scene) - engine.renderer.get.render(scene) + engine.renderer.get.StartNewFrame() + scene.SetShaderGlobal(ASPECT_RATIO_ATTRIBUTE, engine.GetAspectRatio) + engine.renderer.get.UpdateMeshData(scene) + engine.renderer.get.UpdateUniformData(scene) + engine.renderer.get.Render(scene) if engine.showFps: let nanoSecs = getMonoTime().ticks - t0.ticks @@ -175,29 +175,29 @@ min = float(engine.lastNRenderTimes[0]) / 1_000_000 median = float(engine.lastNRenderTimes[engine.lastNRenderTimes.len div 2]) / 1_000_000 max = float(engine.lastNRenderTimes[^1]) / 1_000_000 - engine.window.setTitle(&"{engine.applicationName} ({min:.2}, {median:.2}, {max:.2})") + engine.window.SetTitle(&"{engine.applicationName} ({min:.2}, {median:.2}, {max:.2})") # wrappers for internal things func GpuDevice*(engine: Engine): Device = engine.device func GetWindow*(engine: Engine): auto = engine.window -func GetAspectRatio*(engine: Engine): float32 = engine.GetWindow().size[0] / engine.GetWindow().size[1] -func ShowSystemCursor*(engine: Engine) = engine.window.showSystemCursor() -func HideSystemCursor*(engine: Engine) = engine.window.hideSystemCursor() -func Fullscreen*(engine: Engine): bool = engine.fullscreen +func GetAspectRatio*(engine: Engine): float32 = engine.GetWindow().Size[0] / engine.GetWindow().Size[1] +func ShowSystemCursor*(engine: Engine) = engine.window.ShowSystemCursor() +func HideSystemCursor*(engine: Engine) = engine.window.HideSystemCursor() +func Fullscreen*(engine: Engine): bool = engine.Fullscreen proc `Fullscreen=`*(engine: var Engine, enable: bool) = if enable != engine.fullscreen: engine.fullscreen = enable - engine.window.fullscreen(engine.fullscreen) + engine.window.Fullscreen(engine.fullscreen) func Limits*(engine: Engine): VkPhysicalDeviceLimits = engine.device.physicalDevice.properties.limits proc UpdateInputs*(engine: Engine): bool = - UpdateInputs(engine.window.pendingEvents()) + UpdateInputs(engine.window.PendingEvents()) proc ProcessEvents*(engine: Engine, panel: var Panel) = - let hasMouseNow = panel.contains(MousePositionNormalized(engine.window.size), engine.GetAspectRatio) + let hasMouseNow = panel.Contains(MousePositionNormalized(engine.window.Size), engine.GetAspectRatio) # enter/leave events if hasMouseNow: diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/material.nim --- a/semicongine/material.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/material.nim Sat Jun 08 14:58:25 2024 +0700 @@ -69,7 +69,7 @@ attributes.add &"{key}: {value}" return &"""{material.name}: [{attributes.join(", ")}]""" -proc initMaterialData*( +proc InitMaterialData*( theType: MaterialType, name: string, attributes: Table[string, DataList], @@ -86,7 +86,7 @@ attributes: attributes, ) -proc initMaterialData*( +proc InitMaterialData*( theType: MaterialType, name: string = "", attributes: openArray[(string, DataList)] = @[], @@ -94,7 +94,7 @@ var theName = name if theName == "": theName = &"material instance of '{theType}'" - initMaterialData(theType = theType, name = theName, attributes = attributes.toTable) + InitMaterialData(theType = theType, name = theName, attributes = attributes.toTable) const VERTEX_COLORED_MATERIAL* = MaterialType( diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/mesh.nim --- a/semicongine/mesh.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/mesh.nim Sat Jun 08 14:58:25 2024 +0700 @@ -139,7 +139,7 @@ uvs: openArray[Vec2f] = [], transform: Mat4 = Unit4, instanceTransforms: openArray[Mat4] = [Unit4], - material = EMPTY_MATERIAL.initMaterialData(), + material = EMPTY_MATERIAL.InitMaterialData(), autoResize = true, name: string = "" ): Mesh = @@ -195,7 +195,7 @@ uvs: openArray[Vec2f] = [], transform: Mat4 = Unit4, instanceTransforms: openArray[Mat4] = [Unit4], - material = EMPTY_MATERIAL.initMaterialData(), + material = EMPTY_MATERIAL.InitMaterialData(), name: string = "", ): Mesh = NewMesh( @@ -452,7 +452,7 @@ # GENERATORS ============================================================================ -proc Rect*(width = 1'f32, height = 1'f32, color = "ffffffff", material = EMPTY_MATERIAL.initMaterialData()): Mesh = +proc Rect*(width = 1'f32, height = 1'f32, color = "ffffffff", material = EMPTY_MATERIAL.InitMaterialData()): Mesh = result = Mesh( vertexCount: 4, instanceTransforms: @[Unit4], @@ -473,7 +473,7 @@ result[].InitVertexAttribute("uv", @[NewVec2f(0, 0), NewVec2f(1, 0), NewVec2f(1, 1), NewVec2f(0, 1)]) `material=`(result[], material) -proc Tri*(width = 1'f32, height = 1'f32, color = "ffffffff", material = EMPTY_MATERIAL.initMaterialData()): Mesh = +proc Tri*(width = 1'f32, height = 1'f32, color = "ffffffff", material = EMPTY_MATERIAL.InitMaterialData()): Mesh = result = Mesh( vertexCount: 3, instanceTransforms: @[Unit4], @@ -499,7 +499,7 @@ result[0].add NewVec3f(cos(float32(i) * step) * rX, sin(float32(i) * step) * rY) result[1].add [uint16(0), uint16(i), uint16(i + 1)] -proc Circle*(width = 1'f32, height = 1'f32, nSegments = 12, color = "ffffffff", material = EMPTY_MATERIAL.initMaterialData()): Mesh = +proc Circle*(width = 1'f32, height = 1'f32, nSegments = 12, color = "ffffffff", material = EMPTY_MATERIAL.InitMaterialData()): Mesh = assert nSegments >= 3 result = Mesh( vertexCount: 3 + nSegments, @@ -543,7 +543,7 @@ result[0][i + 1] = NewVec3f(cos(float32(i) * step) * rX, sin(float32(i) * step) * rY) result[1].add [uint16(0), uint16(i), uint16(i + 1)] -proc Grid*(columns, rows: uint16, cellSize = 1.0'f32, color = "ffffffff", material = EMPTY_MATERIAL.initMaterialData()): Mesh = +proc Grid*(columns, rows: uint16, cellSize = 1.0'f32, color = "ffffffff", material = EMPTY_MATERIAL.InitMaterialData()): Mesh = result = Mesh( vertexCount: int((rows + 1) * (columns + 1)), diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/panel.nim --- a/semicongine/panel.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/panel.nim Sat Jun 08 14:58:25 2024 +0700 @@ -19,7 +19,7 @@ instanceAttributes: {TRANSFORM_ATTRIB: Mat4F32, MATERIALINDEX_ATTRIBUTE: UInt16}.toTable, attributes: {"panelTexture": TextureType, "color": Vec4F32}.toTable, ) - PANEL_SHADER* = createShaderConfiguration( + PANEL_SHADER* = CreateShaderConfiguration( name = "panel shader", inputs = [ Attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true), @@ -108,7 +108,7 @@ dirty: true, ) - result.mesh = newMesh( + result.mesh = NewMesh( name = &"panel-{instanceCounter}", positions = newSeq[Vec3f](4), indices = @[ @@ -118,20 +118,20 @@ uvs = @[NewVec2f(0, 1), NewVec2f(1, 1), NewVec2f(1, 0), NewVec2f(0, 0)], transform = transform ) - result.mesh[].renameAttribute("position", POSITION_ATTRIB) - result.mesh[].renameAttribute("uv", UV_ATTRIB) - result.mesh.material = initMaterialData( + result.mesh[].RenameAttribute("position", POSITION_ATTRIB) + result.mesh[].RenameAttribute("uv", UV_ATTRIB) + result.mesh.material = InitMaterialData( theType = PANEL_MATERIAL_TYPE, name = "Panel material", attributes = {"panelTexture": InitDataList(@[texture]), "color": InitDataList(@[color])}, ) inc instanceCounter - result.refresh() + result.Refresh() proc Color*(panel: Panel): Vec4f = panel.mesh.material["color", 0, Vec4f] proc `color=`*(panel: var Panel, value: Vec4f) = - if value != panel.color: + if value != panel.mesh.material["color", 0, Vec4f]: panel.mesh.material["color", 0] = value proc HorizontalAlignment*(panel: Panel): HorizontalAlignment = diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/platform/linux/surface.nim --- a/semicongine/platform/linux/surface.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/platform/linux/surface.nim Sat Jun 08 14:58:25 2024 +0700 @@ -2,7 +2,7 @@ import ../../platform/window proc CreateNativeSurface*(instance: VkInstance, window: NativeWindow): VkSurfaceKHR = - assert instance.valid + assert instance.Valid var surfaceCreateInfo = VkXlibSurfaceCreateInfoKHR( sType: VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, dpy: cast[ptr vulkanapi.Display](window.display), diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/platform/windows/surface.nim --- a/semicongine/platform/windows/surface.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/platform/windows/surface.nim Sat Jun 08 14:58:25 2024 +0700 @@ -2,7 +2,7 @@ import ../../platform/window proc CreateNativeSurface*(instance: VkInstance, window: NativeWindow): VkSurfaceKHR = - assert instance.valid + assert instance.Valid var surfaceCreateInfo = VkWin32SurfaceCreateInfoKHR( sType: VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, hinstance: cast[HINSTANCE](window.hinstance), diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/renderer.nim --- a/semicongine/renderer.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/renderer.nim Sat Jun 08 14:58:25 2024 +0700 @@ -63,7 +63,7 @@ vSync = false, inFlightFrames = 2, ): Renderer = - assert device.vk.valid + assert device.vk.Valid result.device = device result.renderPass = device.CreateRenderPass(shaders, clearColor = clearColor, backFaceCulling = backFaceCulling) @@ -334,10 +334,10 @@ for material in renderer.scenedata[scene].materials[materialType].mitems: dirtyMaterialAttribs.add material.DirtyAttributes material.ClearDirtyAttributes() - assert renderer.scenedata[scene].shaderData[shaderPipeline.vk].uniformBuffers[renderer.swapchain.currentInFlight].vk.valid + assert renderer.scenedata[scene].shaderData[shaderPipeline.vk].uniformBuffers[renderer.swapchain.currentInFlight].vk.Valid if forceAll: for buffer in renderer.scenedata[scene].shaderData[shaderPipeline.vk].uniformBuffers: - assert buffer.vk.valid + assert buffer.vk.Valid var offset = 0'u64 # loop over all uniforms of the shader-shaderPipeline @@ -374,12 +374,11 @@ while not renderer.swapchain.AcquireNextFrame(): checkVkResult renderer.device.vk.vkDeviceWaitIdle() let res = renderer.swapchain.Recreate() - if not res.isSome: - raise newException(Exception, "Unable to recreate swapchain") - var oldSwapchain = renderer.swapchain - renderer.swapchain = res.get() - checkVkResult renderer.device.vk.vkDeviceWaitIdle() - oldSwapchain.Destroy() + if res.isSome: + var oldSwapchain = renderer.swapchain + renderer.swapchain = res.get() + checkVkResult renderer.device.vk.vkDeviceWaitIdle() + oldSwapchain.Destroy() renderer.nextFrameReady = true proc Render*(renderer: var Renderer, scene: Scene) = @@ -427,18 +426,18 @@ renderer.nextFrameReady = false func Valid*(renderer: Renderer): bool = - renderer.device.vk.valid + renderer.device.vk.Valid proc Destroy*(renderer: var Renderer, scene: Scene) = checkVkResult renderer.device.vk.vkDeviceWaitIdle() var scenedata = renderer.scenedata[scene] for buffer in scenedata.vertexBuffers.mvalues: - assert buffer.vk.valid + assert buffer.vk.Valid buffer.Destroy() - if scenedata.indexBuffer.vk.valid: - assert scenedata.indexBuffer.vk.valid + if scenedata.indexBuffer.vk.Valid: + assert scenedata.indexBuffer.vk.Valid scenedata.indexBuffer.Destroy() var destroyedTextures: seq[VkImage] @@ -446,7 +445,7 @@ for (vkPipeline, shaderData) in scenedata.shaderData.mpairs: for buffer in shaderData.uniformBuffers.mitems: - assert buffer.vk.valid + assert buffer.vk.Valid buffer.Destroy() for textures in shaderData.textures.mvalues: diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/resources.nim --- a/semicongine/resources.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/resources.nim Sat Jun 08 14:58:25 2024 +0700 @@ -163,18 +163,18 @@ yield (kind: pcDir, path: components[0]) yielded.incl components[0] -proc loadResource*(path: string, package = DEFAULT_PACKAGE): Stream = +proc LoadResource*(path: string, package = DEFAULT_PACKAGE): Stream = loadResource_intern(path, package = package) -proc loadImage*[T](path: string, package = DEFAULT_PACKAGE): Image[RGBAPixel] = +proc LoadImage*[T](path: string, package = DEFAULT_PACKAGE): Image[RGBAPixel] = if path.splitFile().ext.toLowerAscii == ".bmp": - loadResource_intern(path, package = package).readBMP() + loadResource_intern(path, package = package).ReadBMP() elif path.splitFile().ext.toLowerAscii == ".png": - loadResource_intern(path, package = package).readPNG() + loadResource_intern(path, package = package).ReadPNG() else: raise newException(Exception, "Unsupported image file type: " & path) -proc loadAudio*(path: string, package = DEFAULT_PACKAGE): Sound = +proc LoadAudio*(path: string, package = DEFAULT_PACKAGE): Sound = if path.splitFile().ext.toLowerAscii == ".au": loadResource_intern(path, package = package).ReadAU() elif path.splitFile().ext.toLowerAscii == ".ogg": @@ -182,13 +182,13 @@ else: raise newException(Exception, "Unsupported audio file type: " & path) -proc loadJson*(path: string, package = DEFAULT_PACKAGE): JsonNode = +proc LoadJson*(path: string, package = DEFAULT_PACKAGE): JsonNode = path.loadResource_intern(package = package).readAll().parseJson() -proc loadConfig*(path: string, package = DEFAULT_PACKAGE): Config = +proc LoadConfig*(path: string, package = DEFAULT_PACKAGE): Config = path.loadResource_intern(package = package).loadConfig(filename = path) -proc loadFont*( +proc LoadFont*( path: string, name = "", lineHeightPixels = 80'f32, @@ -201,22 +201,22 @@ thename = path.splitFile().name loadResource_intern(path, package = package).ReadTrueType(name, charset & additional_codepoints.toSeq, lineHeightPixels) -proc loadMeshes*(path: string, defaultMaterial: MaterialType, package = DEFAULT_PACKAGE): seq[MeshTree] = +proc LoadMeshes*(path: string, defaultMaterial: MaterialType, package = DEFAULT_PACKAGE): seq[MeshTree] = loadResource_intern(path, package = package).ReadglTF(defaultMaterial) -proc loadFirstMesh*(path: string, defaultMaterial: MaterialType, package = DEFAULT_PACKAGE): Mesh = +proc LoadFirstMesh*(path: string, defaultMaterial: MaterialType, package = DEFAULT_PACKAGE): Mesh = loadResource_intern(path, package = package).ReadglTF(defaultMaterial)[0].toSeq[0] -proc packages*(): seq[string] = +proc Packages*(): seq[string] = modList_intern() -proc walkResources*(dir = "", package = DEFAULT_PACKAGE): seq[string] = +proc WalkResources*(dir = "", package = DEFAULT_PACKAGE): seq[string] = for i in walkResources_intern(dir, package = package): if i.startsWith(dir): result.add i result.sort() -proc ls*(dir: string, package = DEFAULT_PACKAGE): seq[tuple[kind: PathComponent, path: string]] = +proc List*(dir: string, package = DEFAULT_PACKAGE): seq[tuple[kind: PathComponent, path: string]] = for i in ls_intern(dir = dir, package = package): result.add i result.sort() diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/resources/mesh.nim --- a/semicongine/resources/mesh.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/resources/mesh.nim Sat Jun 08 14:58:25 2024 +0700 @@ -221,7 +221,7 @@ else: attributes["emissiveColor"] = @[NewVec3f(1'f32, 1'f32, 1'f32)] - result = initMaterialData(theType = defaultMaterial, name = materialNode["name"].getStr(), attributes = attributes) + result = InitMaterialData(theType = defaultMaterial, name = materialNode["name"].getStr(), attributes = attributes) proc loadMesh(meshname: string, root: JsonNode, primitiveNode: JsonNode, materials: seq[MaterialData], mainBuffer: seq[uint8]): Mesh = if primitiveNode.hasKey("mode") and primitiveNode["mode"].getInt() != 4: @@ -255,7 +255,7 @@ let materialId = primitiveNode["material"].getInt() result[].material = materials[materialId] else: - result[].material = EMPTY_MATERIAL.initMaterialData() + result[].material = EMPTY_MATERIAL.InitMaterialData() if primitiveNode.hasKey("indices"): assert result[].indexType != None diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/scene.nim --- a/semicongine/scene.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/scene.nim Sat Jun 08 14:58:25 2024 +0700 @@ -49,7 +49,7 @@ scene.dirtyShaderGlobals.add name proc AddShaderGlobal*[T](scene: var Scene, name: string, data: T) = - scene.addShaderGlobalArray(name, [data]) + scene.AddShaderGlobalArray(name, [data]) proc GetShaderGlobalArray*[T](scene: Scene, name: string): ref seq[T] = scene.shaderGlobals[name][T] @@ -65,7 +65,7 @@ scene.dirtyShaderGlobals.add name proc SetShaderGlobal*[T](scene: var Scene, name: string, value: T) = - scene.setShaderGlobalArray(name, [value]) + scene.SetShaderGlobalArray(name, [value]) func DirtyShaderGlobals*(scene: Scene): seq[string] = scene.dirtyShaderGlobals diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/settings.nim --- a/semicongine/settings.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/settings.nim Sat Jun 08 14:58:25 2024 +0700 @@ -71,8 +71,8 @@ let parts = identifier.rsplit(".") if parts.len == 1: raise newException(Exception, &"Setting with name {identifier} has no namespace") - if parts.len == 2: result = setting[T](parts[1], "", parts[0]) - else: result = setting[T](parts[^1], parts[^2], joinPath(parts[0 .. ^3])) + if parts.len == 2: result = Setting[T](parts[1], "", parts[0]) + else: result = Setting[T](parts[^1], parts[^2], joinPath(parts[0 .. ^3])) proc HadConfigUpdate*(): bool = when CONFIGHOTRELOAD == true: diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/text.nim --- a/semicongine/text.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/text.nim Sat Jun 08 14:58:25 2024 +0700 @@ -23,7 +23,7 @@ instanceAttributes: {TRANSFORM_ATTRIB: Mat4F32, MATERIALINDEX_ATTRIBUTE: UInt16}.toTable, attributes: {"fontAtlas": TextureType, "color": Vec4F32}.toTable, ) - TEXT_SHADER* = createShaderConfiguration( + TEXT_SHADER* = CreateShaderConfiguration( name = "font shader", inputs = [ Attr[Mat4](TRANSFORM_ATTRIB, memoryPerformanceHint = PreferFastWrite, perInstance = true), @@ -205,7 +205,7 @@ return result -func Text*(text: Text): seq[Rune] = +func text*(text: Text): seq[Rune] = text.text proc `text=`*(text: var Text, newText: seq[Rune]) = @@ -220,8 +220,8 @@ proc Color*(text: Text): Vec4f = text.mesh.material["color", 0, Vec4f] -proc `color=`*(text: var Text, value: Vec4f) = - if value != text.color: +proc `Color=`*(text: var Text, value: Vec4f) = + if value != text.mesh.material["color", 0, Vec4f]: text.mesh.material["color", 0] = value proc HorizontalAlignment*(text: Text): HorizontalAlignment = @@ -238,7 +238,7 @@ text.verticalAlignment = value text.dirty = true -proc InitText*(font: Font, text = "".toRunes, maxLen: int = text.len, color = NewVec4f(0.07, 0.07, 0.07, 1), verticalAlignment = VerticalAlignment.Center, horizontalAlignment = HorizontalAlignment.Center, maxWidth = 0'f32, transform = Unit4): Text = +proc InitText*(font: Font, text = "".toRunes, maxLen: int = text.len, color = NewVec4f(0.07, 0.07, 0.07, 1), verticalAlignment: VerticalAlignment = Center, horizontalAlignment: HorizontalAlignment = Center, maxWidth = 0'f32, transform = Unit4): Text = var positions = newSeq[Vec3f](int(maxLen * 4)) indices: seq[array[3, uint16]] @@ -251,10 +251,10 @@ ] result = Text(maxLen: maxLen, font: font, dirty: true, horizontalAlignment: horizontalAlignment, verticalAlignment: verticalAlignment, maxWidth: maxWidth) - result.mesh = newMesh(positions = positions, indices = indices, uvs = uvs, name = &"text-{instanceCounter}") - result.mesh[].renameAttribute("position", POSITION_ATTRIB) - result.mesh[].renameAttribute("uv", UV_ATTRIB) - result.mesh.material = TEXT_MATERIAL_TYPE.initMaterialData( + result.mesh = NewMesh(positions = positions, indices = indices, uvs = uvs, name = &"text-{instanceCounter}") + result.mesh[].RenameAttribute("position", POSITION_ATTRIB) + result.mesh[].RenameAttribute("uv", UV_ATTRIB) + result.mesh.material = TEXT_MATERIAL_TYPE.InitMaterialData( name = font.name & " text", attributes = {"fontAtlas": InitDataList(@[font.fontAtlas]), "color": InitDataList(@[color])}, ) @@ -262,4 +262,4 @@ `text=`(result, text) inc instanceCounter - result.refresh() + result.Refresh() diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/buffer.nim --- a/semicongine/vulkan/buffer.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/buffer.nim Sat Jun 08 14:58:25 2024 +0700 @@ -29,8 +29,8 @@ &"Buffer(vk: {buffer.vk}, size: {buffer.size}, usage: {buffer.usage})" proc requirements(buffer: Buffer): MemoryRequirements = - assert buffer.vk.valid - assert buffer.device.vk.valid + assert buffer.vk.Valid + assert buffer.device.vk.Valid var req: VkMemoryRequirements buffer.device.vk.vkGetBufferMemoryRequirements(buffer.vk, addr req) result.size = req.size @@ -41,7 +41,7 @@ result.memoryTypes.add memorytypes[i] proc allocateMemory(buffer: var Buffer, requireMappable: bool, preferVRAM: bool, preferAutoFlush: bool) = - assert buffer.device.vk.valid + assert buffer.device.vk.Valid assert buffer.memoryAllocated == false let requirements = buffer.requirements() @@ -73,7 +73,7 @@ preferVRAM: bool, preferAutoFlush = true, ): Buffer = - assert device.vk.valid + assert device.vk.Valid assert size > 0 result.device = device @@ -99,8 +99,8 @@ proc Copy*(src, dst: Buffer, queue: Queue, dstOffset = 0'u64) = - assert src.device.vk.valid - assert dst.device.vk.valid + assert src.device.vk.Valid + assert dst.device.vk.Valid assert src.device == dst.device assert src.size + dstOffset <= dst.size assert VK_BUFFER_USAGE_TRANSFER_SRC_BIT in src.usage @@ -111,11 +111,11 @@ commandBuffer.vkCmdCopyBuffer(src.vk, dst.vk, 1, addr(copyRegion)) proc Destroy*(buffer: var Buffer) = - assert buffer.device.vk.valid - assert buffer.vk.valid + assert buffer.device.vk.Valid + assert buffer.vk.Valid buffer.device.vk.vkDestroyBuffer(buffer.vk, nil) if buffer.memoryAllocated: - assert buffer.memory.vk.valid + assert buffer.memory.vk.Valid buffer.memory.Free() buffer = Buffer( device: buffer.device, @@ -124,7 +124,7 @@ usage: buffer.usage, memoryAllocated: false, ) - buffer.vk.reset + buffer.vk.Reset template CanMap*(buffer: Buffer): bool = buffer.memory.canMap diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/commandbuffer.nim --- a/semicongine/vulkan/commandbuffer.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/commandbuffer.nim Sat Jun 08 14:58:25 2024 +0700 @@ -11,7 +11,7 @@ buffers*: seq[VkCommandBuffer] proc CreateCommandBufferPool*(device: Device, family: QueueFamily, nBuffers: int): CommandBufferPool = - assert device.vk.valid + assert device.vk.Valid var createInfo = VkCommandPoolCreateInfo( sType: VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, flags: toBits [VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT], @@ -56,8 +56,8 @@ template WithSingleUseCommandBuffer*(device: Device, queue: Queue, commandBuffer, body: untyped): untyped = # TODO? This is super slow, because we call vkQueueWaitIdle block: - assert device.vk.valid - assert queue.vk.valid + assert device.vk.Valid + assert queue.vk.Valid var commandBufferPool = CreateCommandBufferPool(device, queue.family, 1) @@ -83,8 +83,8 @@ proc Destroy*(commandpool: var CommandBufferPool) = - assert commandpool.device.vk.valid - assert commandpool.vk.valid + assert commandpool.device.vk.Valid + assert commandpool.vk.Valid commandpool.device.vk.vkDestroyCommandPool(commandpool.vk, nil) - commandpool.vk.reset + commandpool.vk.Reset diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/descriptor.nim --- a/semicongine/vulkan/descriptor.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/descriptor.nim Sat Jun 08 14:58:25 2024 +0700 @@ -43,7 +43,7 @@ DESCRIPTOR_TYPE_MAP[descriptor.thetype] proc CreateDescriptorSetLayout*(device: Device, descriptors: seq[Descriptor]): DescriptorSetLayout = - assert device.vk.valid + assert device.vk.Valid result.device = device result.descriptors = descriptors @@ -65,13 +65,13 @@ checkVkResult vkCreateDescriptorSetLayout(device.vk, addr(layoutCreateInfo), nil, addr(result.vk)) proc Destroy*(descriptorSetLayout: var DescriptorSetLayout) = - assert descriptorSetLayout.device.vk.valid - assert descriptorSetLayout.vk.valid + assert descriptorSetLayout.device.vk.Valid + assert descriptorSetLayout.vk.Valid descriptorSetLayout.device.vk.vkDestroyDescriptorSetLayout(descriptorSetLayout.vk, nil) - descriptorSetLayout.vk.reset + descriptorSetLayout.vk.Reset proc CreateDescriptorSetPool*(device: Device, counts: seq[(VkDescriptorType, uint32)], maxSets = 1000): DescriptorPool = - assert device.vk.valid + assert device.vk.Valid result.device = device result.maxSets = maxSets @@ -89,21 +89,21 @@ checkVkResult vkCreateDescriptorPool(result.device.vk, addr(poolInfo), nil, addr(result.vk)) proc Reset*(pool: DescriptorPool) = - assert pool.device.vk.valid - assert pool.vk.valid + assert pool.device.vk.Valid + assert pool.vk.Valid checkVkResult vkResetDescriptorPool(pool.device.vk, pool.vk, VkDescriptorPoolResetFlags(0)) proc Destroy*(pool: var DescriptorPool) = - assert pool.device.vk.valid - assert pool.vk.valid + assert pool.device.vk.Valid + assert pool.vk.Valid pool.device.vk.vkDestroyDescriptorPool(pool.vk, nil) - pool.vk.reset + pool.vk.Reset proc AllocateDescriptorSet*(pool: DescriptorPool, layout: DescriptorSetLayout, nframes: int): seq[DescriptorSet] = - assert pool.device.vk.valid - assert pool.vk.valid - assert layout.device.vk.valid - assert layout.vk.valid + assert pool.device.vk.Valid + assert pool.vk.Valid + assert layout.device.vk.Valid + assert layout.vk.Valid var layouts: seq[VkDescriptorSetLayout] var descriptorSets = newSeq[VkDescriptorSet](nframes) @@ -122,9 +122,9 @@ proc WriteDescriptorSet*(descriptorSet: DescriptorSet, bindingBase = 0'u32) = # assumes descriptors of the descriptorSet are arranged interleaved in buffer - assert descriptorSet.layout.device.vk.valid - assert descriptorSet.layout.vk.valid - assert descriptorSet.vk.valid + assert descriptorSet.layout.device.vk.Valid + assert descriptorSet.layout.vk.Valid + assert descriptorSet.vk.Valid var descriptorSetWrites: seq[VkWriteDescriptorSet] var bufferInfos: seq[VkDescriptorBufferInfo] @@ -135,7 +135,7 @@ var imgInfos: seq[seq[VkDescriptorImageInfo]] for descriptor in descriptorSet.layout.descriptors: if descriptor.thetype == Uniform: - assert descriptor.buffer.vk.valid + assert descriptor.buffer.vk.Valid bufferInfos.add VkDescriptorBufferInfo( buffer: descriptor.buffer.vk, offset: descriptor.offset, @@ -153,8 +153,8 @@ elif descriptor.thetype == ImageSampler: var imgInfo: seq[VkDescriptorImageInfo] for img_i in 0 ..< descriptor.count: - assert descriptor.imageviews[img_i].vk.valid - assert descriptor.samplers[img_i].vk.valid + assert descriptor.imageviews[img_i].vk.Valid + assert descriptor.samplers[img_i].vk.Valid imgInfo.add VkDescriptorImageInfo( imageLayout: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, imageView: descriptor.imageviews[img_i].vk, diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/device.nim --- a/semicongine/vulkan/device.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/device.nim Sat Jun 08 14:58:25 2024 +0700 @@ -27,8 +27,8 @@ enabledExtensions: seq[string], queueFamilies: seq[QueueFamily], ): Device = - assert instance.vk.valid - assert physicalDevice.vk.valid + assert instance.vk.Valid + assert physicalDevice.vk.Valid assert queueFamilies.len > 0 result.physicalDevice = physicalDevice @@ -91,18 +91,18 @@ result.queues[family] = Queue(vk: queue, family: family, presentation: family.CanDoPresentation(physicalDevice.surface), graphics: family.CanDoGraphics()) func FirstGraphicsQueue*(device: Device): Option[Queue] = - assert device.vk.valid + assert device.vk.Valid for family, queue in device.queues: if queue.graphics: return some(queue) proc FirstPresentationQueue*(device: Device): Option[Queue] = - assert device.vk.valid + assert device.vk.Valid for family, queue in device.queues: if queue.presentation: return some(queue) proc Destroy*(device: var Device) = - assert device.vk.valid + assert device.vk.Valid device.vk.vkDestroyDevice(nil) - device.vk.reset() + device.vk.Reset() diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/drawable.nim --- a/semicongine/vulkan/drawable.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/drawable.nim Sat Jun 08 14:58:25 2024 +0700 @@ -31,7 +31,7 @@ var offsets: seq[VkDeviceSize] for (name, performanceHint, offset) in drawable.bufferOffsets[pipeline]: - assert vertexBuffers[performanceHint].vk.valid + assert vertexBuffers[performanceHint].vk.Valid buffers.add vertexBuffers[performanceHint].vk offsets.add VkDeviceSize(offset) @@ -44,7 +44,7 @@ pOffsets = offsets.ToCPointer() ) if drawable.indexed: - assert indexBuffer.vk.valid + assert indexBuffer.vk.Valid commandBuffer.vkCmdBindIndexBuffer(indexBuffer.vk, VkDeviceSize(drawable.indexBufferOffset), drawable.indexType) commandBuffer.vkCmdDrawIndexed( indexCount = uint32(drawable.elementCount), diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/framebuffer.nim --- a/semicongine/vulkan/framebuffer.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/framebuffer.nim Sat Jun 08 14:58:25 2024 +0700 @@ -10,15 +10,15 @@ dimension*: Vec2u proc CreateFramebuffer*(device: Device, renderpass: VkRenderPass, attachments: openArray[ImageView], dimension: Vec2u): Framebuffer = - assert device.vk.valid - assert renderpass.valid + assert device.vk.Valid + assert renderpass.Valid result.device = device result.dimension = dimension var theattachments: seq[VkImageView] for a in attachments: - assert a.vk.valid + assert a.vk.Valid theattachments.add a.vk var framebufferInfo = VkFramebufferCreateInfo( sType: VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, @@ -32,7 +32,7 @@ checkVkResult device.vk.vkCreateFramebuffer(addr(framebufferInfo), nil, addr(result.vk)) proc Destroy*(framebuffer: var Framebuffer) = - assert framebuffer.device.vk.valid - assert framebuffer.vk.valid + assert framebuffer.device.vk.Valid + assert framebuffer.vk.Valid framebuffer.device.vk.vkDestroyFramebuffer(framebuffer.vk, nil) - framebuffer.vk.reset + framebuffer.vk.Reset diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/image.nim --- a/semicongine/vulkan/image.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/image.nim Sat Jun 08 14:58:25 2024 +0700 @@ -50,8 +50,8 @@ proc requirements(image: VulkanImage): MemoryRequirements = - assert image.vk.valid - assert image.device.vk.valid + assert image.vk.Valid + assert image.device.vk.Valid var req: VkMemoryRequirements image.device.vk.vkGetImageMemoryRequirements(image.vk, addr req) result.size = req.size @@ -62,7 +62,7 @@ result.memoryTypes.add memorytypes[i] proc allocateMemory(image: var VulkanImage, requireMappable: bool, preferVRAM: bool, preferAutoFlush: bool) = - assert image.device.vk.valid + assert image.device.vk.Valid assert image.memoryAllocated == false let requirements = image.requirements() @@ -122,8 +122,8 @@ commandBuffer.PipelineBarrier([srcStage], [dstStage], imageBarriers = [barrier]) proc Copy*(src: Buffer, dst: VulkanImage, queue: Queue) = - assert src.device.vk.valid - assert dst.device.vk.valid + assert src.device.vk.Valid + assert dst.device.vk.Valid assert src.device == dst.device assert VK_BUFFER_USAGE_TRANSFER_SRC_BIT in src.usage assert VK_IMAGE_USAGE_TRANSFER_DST_BIT in dst.usage @@ -152,7 +152,7 @@ # currently only usable for texture access from shader proc createImage[T](device: Device, queue: Queue, width, height: uint32, depth: PixelDepth, image: Image[T]): VulkanImage = - assert device.vk.valid + assert device.vk.Valid assert width > 0 assert height > 0 assert depth != 2 @@ -226,11 +226,11 @@ stagingBuffer.Destroy() proc Destroy*(image: var VulkanImage) = - assert image.device.vk.valid - assert image.vk.valid + assert image.device.vk.Valid + assert image.vk.Valid image.device.vk.vkDestroyImage(image.vk, nil) if image.memoryAllocated: - assert image.memory.vk.valid + assert image.memory.vk.Valid image.memory.Free() image = VulkanImage( device: image.device, @@ -242,10 +242,10 @@ usage: image.usage, memoryAllocated: false, ) - image.vk.reset + image.vk.Reset proc CreateSampler*(device: Device, sampler: Sampler): VulkanSampler = - assert device.vk.valid + assert device.vk.Valid var samplerInfo = VkSamplerCreateInfo( sType: VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, magFilter: sampler.magnification, @@ -268,10 +268,10 @@ checkVkResult device.vk.vkCreateSampler(addr samplerInfo, nil, addr result.vk) proc Destroy*(sampler: var VulkanSampler) = - assert sampler.device.vk.valid - assert sampler.vk.valid + assert sampler.device.vk.Valid + assert sampler.vk.Valid sampler.device.vk.vkDestroySampler(sampler.vk, nil) - sampler.vk.reset + sampler.vk.Reset proc CreateImageView*( image: VulkanImage, @@ -281,8 +281,8 @@ baseArrayLayer = 0'u32, layerCount = 1'u32 ): ImageView = - assert image.device.vk.valid - assert image.vk.valid + assert image.device.vk.Valid + assert image.vk.Valid var createInfo = VkImageViewCreateInfo( sType: VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, @@ -307,17 +307,17 @@ checkVkResult image.device.vk.vkCreateImageView(addr(createInfo), nil, addr(result.vk)) proc Destroy*(imageview: var ImageView) = - assert imageview.image.device.vk.valid - assert imageview.vk.valid + assert imageview.image.device.vk.Valid + assert imageview.vk.Valid imageview.image.device.vk.vkDestroyImageView(imageview.vk, nil) - imageview.vk.reset() + imageview.vk.Reset() func `$`*(texture: VulkanTexture): string = &"VulkanTexture({texture.image.width}x{texture.image.height})" proc UploadTexture*(device: Device, queue: Queue, texture: Texture): VulkanTexture = - assert device.vk.valid + assert device.vk.Valid if texture.isGrayscale: result.image = createImage(device = device, queue = queue, width = texture.grayImage.width, height = texture.grayImage.height, depth = 1, image = texture.grayImage) else: diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/instance.nim --- a/semicongine/vulkan/instance.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/instance.nim Sat Jun 08 14:58:25 2024 +0700 @@ -85,13 +85,13 @@ result.surface = result.vk.CreateNativeSurface(window) proc Destroy*(instance: var Instance) = - assert instance.vk.valid - assert instance.surface.valid + assert instance.vk.Valid + assert instance.surface.Valid # needs to happen after window is trashed as the driver might have a hook registered for the window destruction instance.vk.vkDestroySurfaceKHR(instance.surface, nil) - instance.surface.reset() + instance.surface.Reset() instance.vk.vkDestroyInstance(nil) - instance.vk.reset() + instance.vk.Reset() const LEVEL_MAPPING = { VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: lvlDebug, @@ -119,7 +119,7 @@ types: openArray[VkDebugUtilsMessageTypeFlagBitsEXT] = @[], callback: DebugCallback = defaultDebugCallback ): Debugger = - assert instance.vk.valid + assert instance.vk.Valid result.instance = instance var severityLevelBits = VkDebugUtilsMessageSeverityFlagBitsEXT.items.toSeq.toBits var typeBits = VkDebugUtilsMessageTypeFlagBitsEXT.items.toSeq.toBits @@ -137,7 +137,7 @@ checkVkResult instance.vk.vkCreateDebugUtilsMessengerEXT(addr(createInfo), nil, addr(result.messenger)) proc Destroy*(debugger: var Debugger) = - assert debugger.messenger.valid - assert debugger.instance.vk.valid + assert debugger.messenger.Valid + assert debugger.instance.vk.Valid debugger.instance.vk.vkDestroyDebugUtilsMessengerEXT(debugger.messenger, nil) - debugger.messenger.reset() + debugger.messenger.Reset() diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/memory.nim --- a/semicongine/vulkan/memory.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/memory.nim Sat Jun 08 14:58:25 2024 +0700 @@ -66,7 +66,7 @@ ) proc Allocate*(device: Device, size: uint64, memoryType: MemoryType): DeviceMemory = - assert device.vk.valid + assert device.vk.Valid assert size > 0 result = DeviceMemory( device: device, @@ -100,8 +100,8 @@ # flush host -> device proc Flush*(memory: DeviceMemory, offset = 0'u64, size = 0'u64) = - assert memory.device.vk.valid - assert memory.vk.valid + assert memory.device.vk.Valid + assert memory.vk.Valid assert memory.needsFlushing var actualSize = size @@ -117,8 +117,8 @@ # flush device -> host proc Invalidate*(memory: DeviceMemory, offset = 0'u64, size = 0'u64) = - assert memory.device.vk.valid - assert memory.vk.valid + assert memory.device.vk.Valid + assert memory.vk.Valid assert memory.needsFlushing var actualSize = size @@ -133,8 +133,8 @@ checkVkResult memory.device.vk.vkInvalidateMappedMemoryRanges(memoryRangeCount = 1, pMemoryRanges = addr(flushrange)) proc Free*(memory: var DeviceMemory) = - assert memory.device.vk.valid - assert memory.vk.valid + assert memory.device.vk.Valid + assert memory.vk.Valid memory.device.vk.vkFreeMemory(memory.vk, nil) - memory.vk.reset + memory.vk.Reset diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/physicaldevice.nim --- a/semicongine/vulkan/physicaldevice.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/physicaldevice.nim Sat Jun 08 14:58:25 2024 +0700 @@ -23,8 +23,8 @@ "Physical device: vk=" & $device.vk & ", name=" & $device.name & ", devicetype=" & $device.devicetype proc GetPhysicalDevices*(instance: Instance): seq[PhysicalDevice] = - assert instance.vk.valid - assert instance.surface.valid + assert instance.vk.Valid + assert instance.surface.Valid var nDevices: uint32 checkVkResult vkEnumeratePhysicalDevices(instance.vk, addr(nDevices), nil) var devices = newSeq[VkPhysicalDevice](nDevices) @@ -39,7 +39,7 @@ result.add device proc GetExtensions*(device: PhysicalDevice): seq[string] = - assert device.vk.valid + assert device.vk.Valid var extensionCount: uint32 checkVkResult vkEnumerateDeviceExtensionProperties(device.vk, nil, addr(extensionCount), nil) if extensionCount > 0: @@ -49,13 +49,13 @@ result.add(CleanString(extension.extensionName)) proc GetSurfaceCapabilities*(device: PhysicalDevice): VkSurfaceCapabilitiesKHR = - assert device.vk.valid - assert device.surface.valid + assert device.vk.Valid + assert device.surface.Valid checkVkResult device.vk.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device.surface, addr(result)) proc GetSurfaceFormats*(device: PhysicalDevice): seq[VkSurfaceFormatKHR] = - assert device.vk.valid - assert device.surface.valid + assert device.vk.Valid + assert device.surface.Valid var n_formats: uint32 checkVkResult vkGetPhysicalDeviceSurfaceFormatsKHR(device.vk, device.surface, addr(n_formats), nil) result = newSeq[VkSurfaceFormatKHR](n_formats) @@ -71,20 +71,20 @@ return format proc FilterSurfaceFormat*(device: PhysicalDevice): VkSurfaceFormatKHR = - assert device.vk.valid - assert device.surface.valid + assert device.vk.Valid + assert device.surface.Valid device.GetSurfaceFormats().FilterSurfaceFormat() proc GetSurfacePresentModes*(device: PhysicalDevice): seq[VkPresentModeKHR] = - assert device.vk.valid - assert device.surface.valid + assert device.vk.Valid + assert device.surface.Valid var n_modes: uint32 checkVkResult vkGetPhysicalDeviceSurfacePresentModesKHR(device.vk, device.surface, addr(n_modes), nil) result = newSeq[VkPresentModeKHR](n_modes) checkVkResult vkGetPhysicalDeviceSurfacePresentModesKHR(device.vk, device.surface, addr(n_modes), result.ToCPointer) proc GetQueueFamilies*(device: PhysicalDevice): seq[QueueFamily] = - assert device.vk.valid + assert device.vk.Valid var nQueuefamilies: uint32 vkGetPhysicalDeviceQueueFamilyProperties(device.vk, addr nQueuefamilies, nil) var queuFamilies = newSeq[VkQueueFamilyProperties](nQueuefamilies) @@ -101,7 +101,7 @@ VK_QUEUE_GRAPHICS_BIT in family.flags proc CanDoPresentation*(family: QueueFamily, surface: VkSurfaceKHR): bool = - assert surface.valid + assert surface.Valid var presentation = VkBool32(false) checkVkResult vkGetPhysicalDeviceSurfaceSupportKHR(family.device.vk, family.index, surface, addr presentation) return bool(presentation) @@ -129,14 +129,14 @@ result.add family proc filterPresentation(families: seq[QueueFamily], surface: VkSurfaceKHR): seq[QueueFamily] = - assert surface.valid + assert surface.Valid for family in families: if family.CanDoPresentation(surface): result.add family proc rateGraphics(device: PhysicalDevice): float = - assert device.vk.valid - assert device.surface.valid + assert device.vk.Valid + assert device.surface.Valid if device.GetQueueFamilies().filterGraphics().filterPresentation(device.surface).len == 0: return -1 if not ("VK_KHR_swapchain" in device.GetExtensions()): @@ -155,8 +155,8 @@ proc FilterBestGraphics*(devices: seq[PhysicalDevice]): PhysicalDevice = var bestVal = -1'f for device in devices: - assert device.vk.valid - assert device.surface.valid + assert device.vk.Valid + assert device.surface.Valid let rating = device.rateGraphics() if rating > bestVal: bestVal = rating diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/pipeline.nim --- a/semicongine/vulkan/pipeline.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/pipeline.nim Sat Jun 08 14:58:25 2024 +0700 @@ -28,7 +28,7 @@ pipeline.shaderConfiguration.samplers proc SetupDescriptors*(pipeline: ShaderPipeline, descriptorPool: DescriptorPool, buffers: seq[Buffer], textures: var Table[string, seq[VulkanTexture]], inFlightFrames: int, emptyTexture: VulkanTexture): seq[DescriptorSet] = - assert pipeline.vk.valid + assert pipeline.vk.Valid assert buffers.len == 0 or buffers.len == inFlightFrames # need to guard against this in case we have no uniforms, then we also create no buffers result = descriptorPool.AllocateDescriptorSet(pipeline.descriptorSetLayout, inFlightFrames) @@ -56,8 +56,8 @@ descriptor.samplers.add emptyTexture.sampler proc CreatePipeline*(device: Device, renderPass: VkRenderPass, shaderConfiguration: ShaderConfiguration, inFlightFrames: int, subpass = 0'u32, backFaceCulling = true): ShaderPipeline = - assert renderPass.valid - assert device.vk.valid + assert renderPass.Valid + assert device.vk.Valid result.device = device result.shaderModules = device.CreateShaderModules(shaderConfiguration) @@ -188,16 +188,16 @@ proc Destroy*(pipeline: var ShaderPipeline) = - assert pipeline.device.vk.valid - assert pipeline.vk.valid - assert pipeline.layout.valid - assert pipeline.descriptorSetLayout.vk.valid + assert pipeline.device.vk.Valid + assert pipeline.vk.Valid + assert pipeline.layout.Valid + assert pipeline.descriptorSetLayout.vk.Valid pipeline.shaderModules[0].Destroy() pipeline.shaderModules[1].Destroy() pipeline.descriptorSetLayout.Destroy() pipeline.device.vk.vkDestroyPipelineLayout(pipeline.layout, nil) pipeline.device.vk.vkDestroyPipeline(pipeline.vk, nil) - pipeline.descriptorSetLayout.reset() - pipeline.layout.reset() - pipeline.vk.reset() + pipeline.descriptorSetLayout.vk.Reset() + pipeline.layout.Reset() + pipeline.vk.Reset() diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/renderpass.nim --- a/semicongine/vulkan/renderpass.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/renderpass.nim Sat Jun 08 14:58:25 2024 +0700 @@ -20,7 +20,7 @@ backFaceCulling = true, inFlightFrames = 2, ): RenderPass = - assert device.vk.valid + assert device.vk.Valid # some asserts for (materialtype, shaderconfig) in shaders: @@ -87,9 +87,9 @@ result.shaderPipelines.add (materialtype, device.CreatePipeline(result.vk, shaderconfig, inFlightFrames, 0, backFaceCulling = backFaceCulling)) proc BeginRenderCommands*(commandBuffer: VkCommandBuffer, renderpass: RenderPass, framebuffer: Framebuffer, oneTimeSubmit: bool) = - assert commandBuffer.valid - assert renderpass.vk.valid - assert framebuffer.vk.valid + assert commandBuffer.Valid + assert renderpass.vk.Valid + assert framebuffer.vk.Valid let w = framebuffer.dimension.x h = framebuffer.dimension.y @@ -136,9 +136,9 @@ proc Destroy*(renderPass: var RenderPass) = - assert renderPass.device.vk.valid - assert renderPass.vk.valid + assert renderPass.device.vk.Valid + assert renderPass.vk.Valid renderPass.device.vk.vkDestroyRenderPass(renderPass.vk, nil) - renderPass.vk.reset + renderPass.vk.Reset for _, pipeline in renderPass.shaderPipelines.mitems: pipeline.Destroy() diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/shader.nim --- a/semicongine/vulkan/shader.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/shader.nim Sat Jun 08 14:58:25 2024 +0700 @@ -151,7 +151,7 @@ device: Device, shaderConfiguration: ShaderConfiguration, ): (ShaderModule, ShaderModule) = - assert device.vk.valid + assert device.vk.Valid assert len(shaderConfiguration.vertexBinary) > 0 assert len(shaderConfiguration.fragmentBinary) > 0 @@ -219,7 +219,7 @@ ) proc Destroy*(shader: var ShaderModule) = - assert shader.device.vk.valid - assert shader.vk.valid + assert shader.device.vk.Valid + assert shader.vk.Valid shader.device.vk.vkDestroyShaderModule(shader.vk, nil) - shader.vk.reset + shader.vk.Reset diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/swapchain.nim --- a/semicongine/vulkan/swapchain.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/swapchain.nim Sat Jun 08 14:58:25 2024 +0700 @@ -39,9 +39,9 @@ oldSwapchain = VkSwapchainKHR(0), vSync = false ): Option[Swapchain] = - assert device.vk.valid - assert device.physicalDevice.vk.valid - assert renderPass.valid + assert device.vk.Valid + assert device.physicalDevice.vk.Valid + assert renderPass.Valid assert inFlightFrames > 0 var capabilities = device.physicalDevice.GetSurfaceCapabilities() @@ -102,13 +102,13 @@ result = none(Swapchain) proc CurrentFramebuffer*(swapchain: Swapchain): Framebuffer = - assert swapchain.device.vk.valid - assert swapchain.vk.valid + assert swapchain.device.vk.Valid + assert swapchain.vk.Valid swapchain.framebuffers[swapchain.currentFramebufferIndex] proc AcquireNextFrame*(swapchain: var Swapchain): bool = - assert swapchain.device.vk.valid - assert swapchain.vk.valid + assert swapchain.device.vk.Valid + assert swapchain.vk.Valid swapchain.queueFinishedFence[swapchain.currentInFlight].Await() @@ -121,15 +121,15 @@ ) if nextImageResult == VK_SUCCESS: - swapchain.queueFinishedFence[swapchain.currentInFlight].reset() + swapchain.queueFinishedFence[swapchain.currentInFlight].Reset() return true else: return false proc Swap*(swapchain: var Swapchain, queue: Queue, commandBuffer: VkCommandBuffer): bool = - assert swapchain.device.vk.valid - assert swapchain.vk.valid - assert queue.vk.valid + assert swapchain.device.vk.Valid + assert swapchain.vk.Valid + assert queue.vk.Valid var waitSemaphores = [swapchain.imageAvailableSemaphore[swapchain.currentInFlight].vk] @@ -167,28 +167,28 @@ proc Destroy*(swapchain: var Swapchain) = - assert swapchain.vk.valid + assert swapchain.vk.Valid for imageview in swapchain.framebufferViews.mitems: - assert imageview.vk.valid + assert imageview.vk.Valid imageview.Destroy() for framebuffer in swapchain.framebuffers.mitems: - assert framebuffer.vk.valid + assert framebuffer.vk.Valid framebuffer.Destroy() for i in 0 ..< swapchain.inFlightFrames: - assert swapchain.queueFinishedFence[i].vk.valid - assert swapchain.imageAvailableSemaphore[i].vk.valid - assert swapchain.renderFinishedSemaphore[i].vk.valid + assert swapchain.queueFinishedFence[i].vk.Valid + assert swapchain.imageAvailableSemaphore[i].vk.Valid + assert swapchain.renderFinishedSemaphore[i].vk.Valid swapchain.queueFinishedFence[i].Destroy() swapchain.imageAvailableSemaphore[i].Destroy() swapchain.renderFinishedSemaphore[i].Destroy() swapchain.device.vk.vkDestroySwapchainKHR(swapchain.vk, nil) - swapchain.vk.reset() + swapchain.vk.Reset() proc Recreate*(swapchain: var Swapchain): Option[Swapchain] = - assert swapchain.vk.valid - assert swapchain.device.vk.valid + assert swapchain.vk.Valid + assert swapchain.device.vk.Valid result = CreateSwapchain( device = swapchain.device, renderPass = swapchain.renderPass, diff -r 02e1d2658ff5 -r 114f395b9144 semicongine/vulkan/syncing.nim --- a/semicongine/vulkan/syncing.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/semicongine/vulkan/syncing.nim Sat Jun 08 14:58:25 2024 +0700 @@ -11,13 +11,13 @@ awaitAction: proc() = nil proc CreateSemaphore*(device: Device): Semaphore = - assert device.vk.valid + assert device.vk.Valid var semaphoreInfo = VkSemaphoreCreateInfo(sType: VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO) result.device = device checkVkResult device.vk.vkCreateSemaphore(addr(semaphoreInfo), nil, addr(result.vk)) proc CreateFence*(device: Device, awaitAction: proc() = nil): Fence = - assert device.vk.valid + assert device.vk.Valid var fenceInfo = VkFenceCreateInfo( sType: VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, flags: toBits [VK_FENCE_CREATE_SIGNALED_BIT] @@ -27,25 +27,25 @@ checkVkResult device.vk.vkCreateFence(addr(fenceInfo), nil, addr(result.vk)) proc Await*(fence: var Fence) = - assert fence.device.vk.valid - assert fence.vk.valid + assert fence.device.vk.Valid + assert fence.vk.Valid checkVkResult vkWaitForFences(fence.device.vk, 1, addr fence.vk, false, high(uint64)) if fence.awaitAction != nil: fence.awaitAction() proc Reset*(fence: var Fence) = - assert fence.device.vk.valid - assert fence.vk.valid + assert fence.device.vk.Valid + assert fence.vk.Valid checkVkResult fence.device.vk.vkResetFences(1, addr fence.vk) proc Destroy*(semaphore: var Semaphore) = - assert semaphore.device.vk.valid - assert semaphore.vk.valid + assert semaphore.device.vk.Valid + assert semaphore.vk.Valid semaphore.device.vk.vkDestroySemaphore(semaphore.vk, nil) - semaphore.vk.reset + semaphore.vk.Reset proc Destroy*(fence: var Fence) = - assert fence.device.vk.valid - assert fence.vk.valid + assert fence.device.vk.Valid + assert fence.vk.Valid fence.device.vk.vkDestroyFence(fence.vk, nil) - fence.vk.reset + fence.vk.Reset diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_audio.nim --- a/tests/test_audio.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_audio.nim Sat Jun 08 14:58:25 2024 +0700 @@ -62,7 +62,7 @@ sleep(1) proc test3() = - mixer[].AddSound("toccata et fugue", loadAudio("toccata_et_fugue.ogg")) + mixer[].AddSound("toccata et fugue", LoadAudio("toccata_et_fugue.ogg")) mixer[].AddSound("ping", NewSound(SineSoundData(500, 0.05, 44100))) mixer[].AddTrack("effects") discard mixer[].Play("toccata et fugue") diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_collision.nim --- a/tests/test_collision.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_collision.nim Sat Jun 08 14:58:25 2024 +0700 @@ -3,18 +3,18 @@ proc main() = var scene = Scene(name: "main") - scene.add rect(color = "f00f") - scene.add rect() - scene.add circle(color = "0f0f") - scene.meshes[0].material = VERTEX_COLORED_MATERIAL.initMaterialData() - scene.meshes[1].material = VERTEX_COLORED_MATERIAL.initMaterialData() - scene.meshes[2].material = VERTEX_COLORED_MATERIAL.initMaterialData() + scene.Add Rect(color = "f00f") + scene.Add Rect() + scene.Add Circle(color = "0f0f") + scene.meshes[0].material = VERTEX_COLORED_MATERIAL.InitMaterialData() + scene.meshes[1].material = VERTEX_COLORED_MATERIAL.InitMaterialData() + scene.meshes[2].material = VERTEX_COLORED_MATERIAL.InitMaterialData() scene.meshes[1].transform = Scale(0.8, 0.8) scene.meshes[2].transform = Scale(0.1, 0.1) - scene.addShaderGlobal("perspective", Unit4F32) + scene.AddShaderGlobal("perspective", Unit4F32) const - shaderConfiguration = createShaderConfiguration( + shaderConfiguration = CreateShaderConfiguration( name = "default shader", inputs = [ Attr[Mat4]("transform", memoryPerformanceHint = PreferFastRead, perInstance = true), @@ -35,8 +35,8 @@ while engine.UpdateInputs() and not KeyIsDown(Escape): if WindowWasResized(): - var winSize = engine.GetWindow().size - scene.setShaderGlobal("perspective", OrthoWindowAspect(winSize[0] / winSize[1])) + var winSize = engine.GetWindow().Size + scene.SetShaderGlobal("perspective", OrthoWindowAspect(winSize[0] / winSize[1])) if KeyIsDown(A): scene.meshes[0].transform = scene.meshes[0].transform * Translate(-0.001, 0, 0) if KeyIsDown(D): scene.meshes[0].transform = scene.meshes[0].transform * Translate(0.001, 0, 0) if KeyIsDown(W): scene.meshes[0].transform = scene.meshes[0].transform * Translate(0, -0.001, 0) @@ -50,7 +50,7 @@ if KeyIsDown(Key.V): scene.meshes[1].transform = scene.meshes[1].transform * Translate(0, 0.001, 0) let hitbox = Collider(theType: Box, transform: scene.meshes[0].transform * Translate(-0.5, -0.5)) let hitsphere = Collider(theType: Sphere, transform: scene.meshes[2].transform, radius: 0.5) - echo intersects(hitbox, hitsphere) + echo Intersects(hitbox, hitsphere) engine.RenderScene(scene) engine.Destroy() diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_font.nim --- a/tests/test_font.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_font.nim Sat Jun 08 14:58:25 2024 +0700 @@ -11,10 +11,10 @@ # build scene var scene = Scene(name: "main") - var font = loadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32) - var origin = initPanel(transform = Scale(0.01, 0.01)) - var main_text = font.initText("".toRunes, maxLen = 255, color = NewVec4f(1, 0.15, 0.15, 1), maxWidth = 1.0, transform = Scale(0.0005, 0.0005)) - var help_text = font.initText("""Controls + var font = LoadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32) + var origin = InitPanel(transform = Scale(0.01, 0.01)) + var main_text = font.InitText("".toRunes, maxLen = 255, color = NewVec4f(1, 0.15, 0.15, 1), maxWidth = 1.0, transform = Scale(0.0005, 0.0005)) + var help_text = font.InitText("""Controls Horizontal alignment: F1: Left @@ -24,16 +24,16 @@ F4: Top F5: Center F6: Bottom""".toRunes, horizontalAlignment = Left, verticalAlignment = Top, transform = Translate(-0.9, -0.9) * Scale(0.0002, 0.0002)) - scene.add origin - scene.add main_text - scene.add help_text + scene.Add origin + scene.Add main_text + scene.Add help_text engine.LoadScene(scene) mixer[].LoadSound("key", "key.ogg") mixer[].SetLevel(0.5) while engine.UpdateInputs() and not KeyIsDown(Escape): var t = cpuTime() - main_text.color = NewVec4f(sin(t) * 0.5 + 0.5, 0.15, 0.15, 1) + main_text.Color = NewVec4f(sin(t) * 0.5 + 0.5, 0.15, 0.15, 1) # add character if main_text.text.len < main_text.maxLen - 1: @@ -66,11 +66,11 @@ elif KeyWasPressed(F5): main_text.verticalAlignment = Center elif KeyWasPressed(F6): main_text.verticalAlignment = Bottom - origin.refresh() + origin.Refresh() main_text.text = main_text.text & Rune('_') - main_text.refresh() + main_text.Refresh() main_text.text = main_text.text[0 ..< ^1] - help_text.refresh() + help_text.Refresh() engine.RenderScene(scene) engine.Destroy() diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_materials.nim --- a/tests/test_materials.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_materials.nim Sat Jun 08 14:58:25 2024 +0700 @@ -13,7 +13,7 @@ WT, WT, WT, WT, WT, WT, WT, RT, RT, RT, RT, RT, RT, RT, ]) - swiss = loadImage[RGBAPixel]("flag.png") + swiss = LoadImage[RGBAPixel]("flag.png") doubleTextureMaterial = MaterialType( name: "Double texture", vertexAttributes: { @@ -22,7 +22,7 @@ }.toTable, attributes: {"tex1": TextureType, "tex2": TextureType}.toTable ) - material = initMaterialData( + material = InitMaterialData( theType = doubleTextureMaterial, name = "swiss-thai", attributes = { @@ -32,15 +32,15 @@ ) proc main() = - var flag = rect() + var flag = Rect() flag.material = material var scene = Scene(name: "main", meshes: @[flag]) - scene.addShaderGlobalArray("test2", @[NewVec4f(), NewVec4f()]) + scene.AddShaderGlobalArray("test2", @[NewVec4f(), NewVec4f()]) var engine = InitEngine("Test materials") const - shaderConfiguration1 = createShaderConfiguration( + shaderConfiguration1 = CreateShaderConfiguration( name = "shader 1", inputs = [ Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), @@ -70,7 +70,7 @@ var t = cpuTime() while engine.UpdateInputs() and not KeyIsDown(Escape): var d = float32(cpuTime() - t) - setShaderGlobalArray(scene, "test2", @[NewVec4f(d), NewVec4f(d * 2)]) + SetShaderGlobalArray(scene, "test2", @[NewVec4f(d), NewVec4f(d * 2)]) engine.RenderScene(scene) engine.Destroy() diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_mesh.nim --- a/tests/test_mesh.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_mesh.nim Sat Jun 08 14:58:25 2024 +0700 @@ -13,12 +13,12 @@ proc main() = var scenes = [ - Scene(name: "Donut", meshes: loadMeshes("donut.glb", MeshMaterial)[0].toSeq), + Scene(name: "Donut", meshes: LoadMeshes("donut.glb", MeshMaterial)[0].toSeq), ] var engine = InitEngine("Test meshes") const - shaderConfiguration = createShaderConfiguration( + shaderConfiguration = CreateShaderConfiguration( name = "default shader", inputs = [ Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), @@ -49,8 +49,8 @@ engine.InitRenderer({MeshMaterial: shaderConfiguration}) for scene in scenes.mitems: - scene.addShaderGlobal("projection", Unit4F32) - scene.addShaderGlobal("view", Unit4F32) + scene.AddShaderGlobal("projection", Unit4F32) + scene.AddShaderGlobal("view", Unit4F32) engine.LoadScene(scene) var @@ -78,12 +78,12 @@ elevation = 0'f32 azimut = 0'f32 - let ratio = engine.GetWindow().size[0] / engine.GetWindow().size[1] + let ratio = engine.GetWindow().Size[0] / engine.GetWindow().Size[1] size *= 1'f32 + MouseWheel() * 0.05 azimut += MouseMove().x / 180'f32 elevation -= MouseMove().y / 180'f32 - scenes[currentScene].setShaderGlobal("projection", Perspective(PI / 2, ratio, -0.5, 1)) - scenes[currentScene].setShaderGlobal( + scenes[currentScene].SetShaderGlobal("projection", Perspective(PI / 2, ratio, -0.5, 1)) + scenes[currentScene].SetShaderGlobal( "view", Scale(size, size, size) * Rotate(elevation, NewVec3f(1, 0, 0)) * Rotate(azimut, Yf32) ) diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_noise.nim --- a/tests/test_noise.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_noise.nim Sat Jun 08 14:58:25 2024 +0700 @@ -8,9 +8,9 @@ for y in 0 ..< h: for x in 0 ..< w: let v = ( - perlin(NewVec2f(float(x) * 0.01, float(y) * 0.01)) * 0.7 + - perlin(NewVec2f(float(x) * 0.05, float(y) * 0.05)) * 0.25 + - perlin(NewVec2f(float(x) * 0.2, float(y) * 0.2)) * 0.05 + Perlin(NewVec2f(float(x) * 0.01, float(y) * 0.01)) * 0.7 + + Perlin(NewVec2f(float(x) * 0.05, float(y) * 0.05)) * 0.25 + + Perlin(NewVec2f(float(x) * 0.2, float(y) * 0.2)) * 0.05 ) o = o & $(int((v * 0.5 + 0.5) * 255)) & " " o = o & "\n" diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_panel.nim --- a/tests/test_panel.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_panel.nim Sat Jun 08 14:58:25 2024 +0700 @@ -28,21 +28,21 @@ # build scene # var - font = loadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32) + font = LoadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32) scene = Scene(name: "main") - origin = initPanel( + origin = InitPanel( transform = Scale(0.005, 0.005), color = NewVec4f(1, 1, 1, 1), texture = Texture(isGrayscale: false, colorImage: NewImage[RGBAPixel](3, 3, [T, B, T, B, B, B, T, B, T]), sampler: NEAREST_SAMPLER), ) - button = initPanel( + button = InitPanel( transform = Translate(0.2, 0.1) * Scale(0.3, 0.1), color = NewVec4f(1, 0, 0, 0.5), onMouseDown = click, onMouseEnter = enter, onMouseLeave = leave ) - help_text = font.initText("""Controls + help_text = font.InitText("""Controls Horizontal alignment: F1: Left @@ -56,12 +56,12 @@ Left click: Increase counter Right click: Decrease counter""".toRunes, horizontalAlignment = Left, verticalAlignment = Top, transform = Translate(-0.9, -0.9) * Scale(0.0002, 0.0002)) - counterText = font.initText(($counter).toRunes, maxLen = 99, transform = Translate(0.2, 0.1) * Scale(0.0004, 0.0004)) + counterText = font.InitText(($counter).toRunes, maxLen = 99, transform = Translate(0.2, 0.1) * Scale(0.0004, 0.0004)) - scene.add counterText - scene.add button - scene.add help_text - scene.add origin + scene.Add counterText + scene.Add button + scene.Add help_text + scene.Add origin engine.LoadScene(scene) while engine.UpdateInputs() and not KeyIsDown(Escape): @@ -86,10 +86,10 @@ engine.ProcessEvents(button) - button.refresh() - counterText.refresh() - origin.refresh() - help_text.refresh() + button.Refresh() + counterText.Refresh() + origin.Refresh() + help_text.Refresh() engine.RenderScene(scene) engine.Destroy() diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_resources.nim --- a/tests/test_resources.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_resources.nim Sat Jun 08 14:58:25 2024 +0700 @@ -6,27 +6,27 @@ import semicongine proc list_all_mods_all_files() = - for package in packages(): + for package in Packages(): echo &"Files in package {package}:" - for i in walkResources(package = package): - echo " ", i, ": ", i.loadResource(package = package).readAll().len + for i in WalkResources(package = package): + echo " ", i, ": ", i.LoadResource(package = package).readAll().len proc print_ls(dir, package: string, indent = 2) = - for i in dir.ls(package = package): + for i in dir.List(package = package): if i.kind == pcDir: echo "".align(indent), i.path, "/" print_ls(dir.joinPath(i.path), package = package, indent = indent + 2) else: - echo "".align(indent), i.path, ": ", dir.joinPath(i.path).loadResource(package = package).readAll().len + echo "".align(indent), i.path, ": ", dir.joinPath(i.path).LoadResource(package = package).readAll().len proc list_files() = - for package in packages(): + for package in Packages(): echo &"Recursive walk of package {package}: " print_ls("", package = package) proc main() = - echo "Packages available: ", packages() + echo "Packages available: ", Packages() list_all_mods_all_files() list_files() diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_storage.nim --- a/tests/test_storage.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_storage.nim Sat Jun 08 14:58:25 2024 +0700 @@ -7,32 +7,32 @@ const KEY = "test" # get default - assert storage.load(KEY, 0) == default(type(TEST_VALUE)) + assert storage.Load(KEY, 0) == default(type(TEST_VALUE)) # save and load custom - store(storage, KEY, TEST_VALUE) - assert storage.load(KEY, 0) == TEST_VALUE + Store(storage, KEY, TEST_VALUE) + assert storage.Load(KEY, 0) == TEST_VALUE proc stressTest(storage: StorageType) = for i in 1 .. 10000: let key = &"key-{i}" - store(storage, key, i) - assert storage.load(key, 0) == i + Store(storage, key, i) + assert storage.Load(key, 0) == i proc main() = - SystemStorage.purge() + SystemStorage.Purge() echo "SystemStorage: Testing simple store/load" SystemStorage.testSimple() - UserStorage.purge() + UserStorage.Purge() echo "UserStorage: Testing simple store/load" UserStorage.testSimple() echo "Stress test with 10'000 saves/loads" SystemStorage.stressTest() - SystemStorage.purge() - UserStorage.purge() + SystemStorage.Purge() + UserStorage.Purge() when isMainModule: diff -r 02e1d2658ff5 -r 114f395b9144 tests/test_vulkan_wrapper.nim --- a/tests/test_vulkan_wrapper.nim Tue Jun 04 22:08:48 2024 +0700 +++ b/tests/test_vulkan_wrapper.nim Sat Jun 08 14:58:25 2024 +0700 @@ -20,7 +20,7 @@ }.toTable, attributes: {"baseTexture": TextureType}.toTable ) - mat = Mat1Type.initMaterialData( + mat = Mat1Type.InitMaterialData( name = "mat", attributes = { "baseTexture": InitDataList(@[Texture(isGrayscale: false, colorImage: Image[RGBAPixel](width: 5, height: 5, imagedata: @[ @@ -41,7 +41,7 @@ }.toTable, attributes: {"baseTexture": TextureType}.toTable ) - mat2 = Mat2Type.initMaterialData( + mat2 = Mat2Type.InitMaterialData( name = "mat2", attributes = { "baseTexture": InitDataList(@[Texture(isGrayscale: false, colorImage: Image[RGBAPixel](width: 5, height: 5, imagedata: @[ @@ -53,7 +53,7 @@ ]), sampler: sampler)]) }.toTable ) - mat3 = SINGLE_COLOR_MATERIAL.initMaterialData( + mat3 = SINGLE_COLOR_MATERIAL.InitMaterialData( name = "mat3", attributes = { "color": InitDataList(@[NewVec4f(0, 1, 0, 1)]) @@ -62,21 +62,21 @@ proc scene_different_mesh_types(): seq[Mesh] = @[ - newMesh( + NewMesh( positions = [NewVec3f(0.0, -0.5), NewVec3f(0.5, 0.5), NewVec3f(-0.5, 0.5)], uvs = [NewVec2f(0.0, -0.5), NewVec2f(0.5, 0.5), NewVec2f(-0.5, 0.5)], colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], material = mat, transform = Translate(-0.7, -0.5), ), - newMesh( + NewMesh( positions = [NewVec3f(0.0, -0.4), NewVec3f(0.4, 0.4), NewVec3f(-0.4, 0.5)], uvs = [NewVec2f(0.0, -0.4), NewVec2f(0.4, 0.4), NewVec2f(-0.4, 0.5)], colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], material = mat, transform = Translate(0, -0.5), ), - newMesh( + NewMesh( positions = [NewVec3f(0.0, 0.5), NewVec3f(0.5, -0.5), NewVec3f(-0.5, -0.5)], uvs = [NewVec2f(0.0, 0.5), NewVec2f(0.5, -0.5), NewVec2f(-0.5, -0.5)], colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], @@ -84,7 +84,7 @@ material = mat2, transform = Translate(0.7, -0.5), ), - newMesh( + NewMesh( positions = [NewVec3f(0.0, 0.4), NewVec3f(0.4, -0.4), NewVec3f(-0.4, -0.4)], uvs = [NewVec2f(0.0, 0.4), NewVec2f(0.4, -0.4), NewVec2f(-0.4, -0.4)], colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], @@ -92,7 +92,7 @@ material = mat2, transform = Translate(-0.7, 0.5), ), - newMesh( + NewMesh( positions = [NewVec3f(0.4, 0.5), NewVec3f(0.9, -0.3), NewVec3f(0.0, -0.3)], uvs = [NewVec2f(0.4, 0.5), NewVec2f(0.9, -0.3), NewVec2f(0.0, -0.3)], colors = [NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1)], @@ -101,7 +101,7 @@ material = mat2, transform = Translate(0, 0.5), ), - newMesh( + NewMesh( positions = [NewVec3f(0.4, 0.5), NewVec3f(0.9, -0.3), NewVec3f(0.0, -0.3)], uvs = [NewVec2f(0.4, 0.5), NewVec2f(0.9, -0.3), NewVec2f(0.0, -0.3)], colors = [NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1)], @@ -114,21 +114,21 @@ proc scene_simple(): seq[Mesh] = @[ - newMesh( + NewMesh( positions = [NewVec3f(0.0, -0.3), NewVec3f(0.3, 0.3), NewVec3f(-0.3, 0.3)], colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], uvs = [NewVec2f(0.0, -0.3), NewVec2f(0.3, 0.3), NewVec2f(-0.3, 0.3)], material = mat, transform = Translate(0.4, 0.4), ), - newMesh( + NewMesh( positions = [NewVec3f(0.0, -0.5), NewVec3f(0.5, 0.5), NewVec3f(-0.5, 0.5)], colors = [NewVec4f(1.0, 0.0, 0.0, 1), NewVec4f(0.0, 1.0, 0.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], uvs = [NewVec2f(0.0, -0.5), NewVec2f(0.5, 0.5), NewVec2f(-0.5, 0.5)], material = mat, transform = Translate(0.4, -0.4), ), - newMesh( + NewMesh( positions = [NewVec3f(0.0, -0.6), NewVec3f(0.6, 0.6), NewVec3f(-0.6, 0.6)], colors = [NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1), NewVec4f(1.0, 1.0, 0.0, 1)], uvs = [NewVec2f(0.0, -0.6), NewVec2f(0.6, 0.6), NewVec2f(-0.6, 0.6)], @@ -137,7 +137,7 @@ material = mat, transform = Translate(-0.4, 0.4), ), - newMesh( + NewMesh( positions = [NewVec3f(0.0, -0.8), NewVec3f(0.8, 0.8), NewVec3f(-0.8, 0.8)], colors = [NewVec4f(0.0, 0.0, 1.0, 1), NewVec4f(0.0, 0.0, 1.0, 1), NewVec4f(0.0, 0.0, 1.0, 1)], uvs = [NewVec2f(0.0, -0.8), NewVec2f(0.8, 0.8), NewVec2f(-0.8, 0.8)], @@ -149,9 +149,9 @@ ] proc scene_primitives(): seq[Mesh] = - var r = rect(color = "ff0000") - var t = tri(color = "0000ff") - var c = circle(color = "00ff00") + var r = Rect(color = "ff0000") + var t = Tri(color = "0000ff") + var c = Circle(color = "00ff00") r.material = mat t.material = mat c.material = mat @@ -162,7 +162,7 @@ proc scene_flag(): seq[Mesh] = @[ - newMesh( + NewMesh( positions = [NewVec3f(-1.0, -1.0), NewVec3f(1.0, -1.0), NewVec3f(1.0, 1.0), NewVec3f(-1.0, 1.0)], uvs = [NewVec2f(-1.0, -1.0), NewVec2f(1.0, -1.0), NewVec2f(1.0, 1.0), NewVec2f(-1.0, 1.0)], colors = [NewVec4f(-1, -1, 1, 1), NewVec4f(1, -1, 1, 1), NewVec4f(1, 1, 1, 1), NewVec4f(-1, 1, 1, 1)], @@ -174,8 +174,8 @@ proc scene_multi_material(): seq[Mesh] = var - r1 = rect(color = "ffffff") - r2 = rect(color = "000000") + r1 = Rect(color = "ffffff") + r2 = Rect(color = "000000") r1.material = mat r2.material = mat3 r1.transform = Translate(NewVec3f(-0.5)) @@ -187,7 +187,7 @@ # INIT RENDERER: const - shaderConfiguration1 = createShaderConfiguration( + shaderConfiguration1 = CreateShaderConfiguration( name = "shader1", inputs = [ Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), @@ -202,7 +202,7 @@ vertexCode = """gl_Position = vec4(position, 1.0) * transform; outcolor = color;""", fragmentCode = "color = texture(baseTexture, outcolor.xy) * 0.5 + outcolor * 0.5;", ) - shaderConfiguration2 = createShaderConfiguration( + shaderConfiguration2 = CreateShaderConfiguration( name = "shader2", inputs = [ Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead),