diff src/zamikongine/vulkan.nim @ 38:c3c963e7c1a6

did: tons of stuff, input, refactoring, fix some errors, some template improvment, sorry for super-commit
author Sam <sam@basx.dev>
date Wed, 18 Jan 2023 09:52:03 +0700
parents b55d6ecde79d
children
line wrap: on
line diff
--- a/src/zamikongine/vulkan.nim	Mon Jan 16 00:51:03 2023 +0700
+++ b/src/zamikongine/vulkan.nim	Wed Jan 18 09:52:03 2023 +0700
@@ -8,23 +8,30 @@
 when defined(linux):
   import x11/x
   import x11/xlib
+  const vkDLL = "libvulkan.so.1"
+else:
+  type
+    Display* = ptr object
+    VisualID* = ptr object
+    Window* = ptr object
+
 when defined(windows):
+  const vkDLL = "vulkan-1.dll"
   import winim
+else:
+  type
+    HINSTANCE* = ptr object
+    HWND* = ptr object
+    HMONITOR* = ptr object
+    HANDLE* = ptr object
+    SECURITY_ATTRIBUTES* = ptr object
+    DWORD* = ptr object
+    LPCWSTR* = ptr object
 
 var vkGetProc: proc(procName: cstring): pointer {.cdecl.}
 
 import dynlib
 
-when defined(windows):
-  {. emit: """#define VK_USE_PLATFORM_WIN32_KHR""" .}
-  const vkDLL = "vulkan-1.dll"
-elif defined(linux):
-  {.passl: gorge("pkg-config --libs vulkan").}
-  {. emit: """#define VK_USE_PLATFORM_X11_KHR""" .}
-  const vkDLL = "libvulkan.so.1"
-else:
-  raise quit("Unsupported platform")
-
 let vkHandleDLL = loadLib(vkDLL)
 if isNil(vkHandleDLL):
   quit("could not load: " & vkDLL)
@@ -1188,22 +1195,6 @@
 
 # Types
 
-# stub types if we are on the wrong platform, so we don't need to "when" all platform functions
-when not defined(linux):
-  type
-    Display* = ptr object
-    VisualID* = ptr object
-    Window* = ptr object
-when not defined(windows):
-  type
-    HINSTANCE* = ptr object
-    HWND* = ptr object
-    HMONITOR* = ptr object
-    HANDLE* = ptr object
-    SECURITY_ATTRIBUTES* = ptr object
-    DWORD* = ptr object
-    LPCWSTR* = ptr object
-
 type
   RROutput* = ptr object
   wl_display* = ptr object