Skip to content

Commit

Permalink
Fix dylib for MacOSX and create Windows only loader section
Browse files Browse the repository at this point in the history
  • Loading branch information
lmariscal committed Nov 6, 2019
1 parent c584ddf commit 82525e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 5 additions & 1 deletion examples/tvulkan.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions src/nimgl/vulkan.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand Down Expand Up @@ -9263,6 +9264,7 @@ proc loadVK_KHR_pipeline_executable_properties*() =
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.