Try to load the library and all the required entry points
| 51 | |
| 52 | // Try to load the library and all the required entry points |
| 53 | bool loadLibrary() |
| 54 | { |
| 55 | if (library) |
| 56 | return true; |
| 57 | |
| 58 | library = dlopen("libvulkan.so.1", RTLD_LAZY); |
| 59 | |
| 60 | if (!library) |
| 61 | return false; |
| 62 | |
| 63 | if (!loadEntryPoint(vkGetInstanceProcAddr, "vkGetInstanceProcAddr")) |
| 64 | { |
| 65 | dlclose(library); |
| 66 | library = nullptr; |
| 67 | return false; |
| 68 | } |
| 69 | |
| 70 | if (!loadEntryPoint(vkEnumerateInstanceLayerProperties, "vkEnumerateInstanceLayerProperties")) |
| 71 | { |
| 72 | dlclose(library); |
| 73 | library = nullptr; |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | if (!loadEntryPoint(vkEnumerateInstanceExtensionProperties, "vkEnumerateInstanceExtensionProperties")) |
| 78 | { |
| 79 | dlclose(library); |
| 80 | library = nullptr; |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | template <typename T> |
| 88 | bool loadEntryPoint(T& entryPoint, const char* name) |