changeset 546:db4e583b40c3

did: a few fixes for new API
author Sam <sam@basx.dev>
date Sat, 25 Feb 2023 00:44:05 +0700
parents 39aed3128be7
children c3b6981764a5
files examples/E10_pong.nim src/semicongine/color.nim src/semicongine/engine.nim src/semicongine/vulkan/api.nim src/semicongine/vulkan_helpers.nim
diffstat 5 files changed, 15 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/examples/E10_pong.nim	Fri Feb 24 01:32:45 2023 +0700
+++ b/examples/E10_pong.nim	Sat Feb 25 00:44:05 2023 +0700
@@ -18,6 +18,8 @@
   backgroundColor = RGBAfromHex("FAC034").gamma(2.2)
   ballSpeed = 60'f
 
+echo RGBAfromHex("FAC034")
+echo RGBAfromHex("FAC034").gamma(2.2)
 var
   uniforms = Uniforms()
   pipeline: RenderPipeline[Vertex, Uniforms]
--- a/src/semicongine/color.nim	Fri Feb 24 01:32:45 2023 +0700
+++ b/src/semicongine/color.nim	Sat Feb 25 00:44:05 2023 +0700
@@ -12,9 +12,9 @@
     hex = hex[0] & hex[0] & hex[1] & hex[1] & hex[2] & hex[2]
   var r, g, b: uint8
   assert hex.len == 6
-  assert parseHex(hex[0 .. 1], r) == 2
-  assert parseHex(hex[2 .. 3], g) == 2
-  assert parseHex(hex[4 .. 5], b) == 2
+  discard parseHex(hex[0 .. 1], r) == 2
+  discard parseHex(hex[2 .. 3], g) == 2
+  discard parseHex(hex[4 .. 5], b) == 2
   return Vec3([float32(r), float32(g), float32(b)]) / 255'f
 
 func RGBAfromHex*(value: string): Vec4 =
@@ -32,10 +32,10 @@
     hex = hex & "ff"
   assert hex.len == 8
   var r, g, b, a: uint8
-  assert parseHex(hex[0 .. 1], r) == 2
-  assert parseHex(hex[2 .. 3], g) == 2
-  assert parseHex(hex[4 .. 5], b) == 2
-  assert parseHex(hex[6 .. 7], a) == 2
+  discard parseHex(hex[0 .. 1], r)
+  discard parseHex(hex[2 .. 3], g)
+  discard parseHex(hex[4 .. 5], b)
+  discard parseHex(hex[6 .. 7], a)
   return Vec4([float32(r), float32(g), float32(b), float32(a)]) / 255'f
 
 func gamma*[T: Vec3|Vec4](color: T, gamma: float32): auto =
--- a/src/semicongine/engine.nim	Fri Feb 24 01:32:45 2023 +0700
+++ b/src/semicongine/engine.nim	Sat Feb 25 00:44:05 2023 +0700
@@ -643,8 +643,7 @@
           dstArrayElement: 0,
           descriptorType: VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
           descriptorCount: 1,
-          pBufferInfo: cast[ptr ptr VkDescriptorBufferInfo](addr(bufferInfos[i][
-              0])),
+          pBufferInfo: addr(bufferInfos[i][0]),
         )
       vkUpdateDescriptorSets(result.device, 1, addr(descriptorWrite), 0, nil)
 
--- a/src/semicongine/vulkan/api.nim	Fri Feb 24 01:32:45 2023 +0700
+++ b/src/semicongine/vulkan/api.nim	Sat Feb 25 00:44:05 2023 +0700
@@ -11626,4 +11626,4 @@
 
 converter VkBool2NimBool*(a: VkBool32): bool = a > 0
 converter NimBool2VkBool*(a: bool): VkBool32 = VkBool32(a)
-proc `$`*(x: uint32): string {.raises: [].} = addInt(result, x)
\ No newline at end of file
+proc `$`*(x: uint32): string {.raises: [].} = addInt(result, x)
--- a/src/semicongine/vulkan_helpers.nim	Fri Feb 24 01:32:45 2023 +0700
+++ b/src/semicongine/vulkan_helpers.nim	Sat Feb 25 00:44:05 2023 +0700
@@ -144,8 +144,7 @@
   var usableLayers = newSeq[cstring]()
 
   when ENABLEVULKANVALIDATIONLAYERS:
-    const desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring,
-        "VK_LAYER_MESA_overlay".cstring]
+    const desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring, "VK_LAYER_MESA_overlay".cstring]
   else:
     const desiredLayers: array[0, string] = []
   for layer in desiredLayers:
@@ -155,7 +154,7 @@
   echo "Available validation layers: ", availableLayers
   echo "Using validation layers: ", usableLayers
   echo "Available extensions: ", availableExtensions
-  echo "Using extensions: ", requiredExtensions
+  echo "Using instance extensions: ", requiredExtensions
 
   var appinfo = VkApplicationInfo(
     sType: VK_STRUCTURE_TYPE_APPLICATION_INFO,
@@ -174,14 +173,10 @@
         requiredExtensions[0]))
   )
   checkVkResult vkCreateInstance(addr(createinfo), nil, addr(result))
-  for extension in requiredExtensions:
+  let other_extensions = @["VK_KHR_swapchain".cstring]
+  for extension in requiredExtensions & other_extensions:
     result.loadExtension($extension)
 
-  # loadVK_KHR_surface(result)
-  # loadVK_KHR_swapchain(result)
-  when ENABLEVULKANVALIDATIONLAYERS:
-    loadVK_EXT_debug_utils(result)
-
 
 proc getVulcanDevice*(
   physicalDevice: var VkPhysicalDevice,