Skip to content
Permalink
Browse files

Fix dylib for MacOSX and create Windows only loader section

  • Loading branch information...
lmariscal committed Nov 6, 2019
1 parent c584ddf commit 82525e1015d965665bca01f3d333d8d88c08a39d
Showing with 13 additions and 7 deletions.
  1. +5 −1 examples/tvulkan.nim
  2. +8 −6 src/nimgl/vulkan.nim
@@ -36,12 +36,16 @@ proc cleanUp() =
glfwTerminate()

proc initVulkan() =
when defined(macosx):
let vkVersion = vkApiVersion1_0.uint32
else:
let vkVersion = vkApiVersion1_1.uint32
var appInfo = newVkApplicationInfo(
pApplicationName = "NimGL Vulkan Example",
applicationVersion = vkMakeVersion(1, 0, 0),
pEngineName = "No Engine",
engineVersion = vkMakeVersion(1, 0, 0),
apiVersion = vkApiVersion1_1
apiVersion = vkVersion
)

var glfwExtensionCount: uint32 = 0
@@ -13,7 +13,7 @@ when not defined(vkCustomLoader):
when defined(windows):
const vkDLL = "vulkan-1.dll"
elif defined(macosx):
quit("libvulkan.1.dylib")
const vkDLL = "libMoltenVK.dylib"
else:
const vkDLL = "libvulkan.so.1"

@@ -26,9 +26,10 @@ when not defined(vkCustomLoader):
quit("failed to load `vkGetInstanceProcAddr` from " & vkDLL)

vkGetProc = proc(procName: cstring): pointer {.cdecl.} =
result = vkGetProcAddress(procName)
if result != nil:
return
when defined(windows):
result = vkGetProcAddress(procName)
if result != nil:
return
result = symAddr(vkHandleDLL, procName)
if result == nil:
raiseInvalidLibrary(procName)
proc vkInit*(load1_0: bool = true, load1_1: bool = true): bool =
if load1_0:
vkLoad1_0()
if load1_1:
vkLoad1_1()
when not defined(macosx):
if load1_1:
vkLoad1_1()
return true

0 comments on commit 82525e1

Please sign in to comment.
You can’t perform that action at this time.