diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a89ace..d844d5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,12 @@ project(Gryphn) add_compile_definitions(GN_PLATFORM_LINUX GN_WINDOW_X11 GN_REVEAL_IMPL) -add_subdirectory(projects/core/) # build gryphn code +add_subdirectory(projects/core/) # build gryphn core +add_subdirectory(projects/loader) # build gryphn loader add_subdirectory(projects/apis/vulkan/) add_library(Gryphn INTERFACE) -target_link_libraries(Gryphn INTERFACE GryphnCore GryphnVulkanImpl) +target_link_libraries(Gryphn INTERFACE GryphnCore GryphnLoader GryphnVulkanImpl) # set(CMAKE_EXPORT_COMPILE_COMMANDS on) # project(Gryphn) diff --git a/projects/core/src/instance/gryphn_instance.c b/projects/core/src/instance/gryphn_instance.c index 4245212..45eff1d 100644 --- a/projects/core/src/instance/gryphn_instance.c +++ b/projects/core/src/instance/gryphn_instance.c @@ -1,13 +1,10 @@ #include "gryphn_instance.h" #include #include "instance/gryphn_instance.h" -#include "gryphn_handles.h" +#include "loader/src/gryphn_loader.h" -gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, gnInstanceInfo info) { - // *instanceHandlePtr = malloc(sizeof(struct gnInstance_t)); - // gnInstanceHandle instance = *instanceHandlePtr; - // if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API; - // instance->loadDeviceFunctions = gnFalse; +gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) { + *instance = malloc(sizeof(struct gnInstance_t)); // instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI); // if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY; // instance->functions = gnLoadFunctions(instance); @@ -15,8 +12,6 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instanceHandlePtr, gnInstanceInf // if (info.debugger) // instance->debugger = info.debugger; - // instance->loadCommandFunctions = gnFalse; - // instance->loadDeviceFunctions = gnFalse; // return instance->functions->_gnCreateInstance(instance, info); return GN_SUCCESS; } diff --git a/projects/core/src/instance/init/gryphn_dynamic_library.h b/projects/core/src/instance/init/gryphn_dynamic_library.h deleted file mode 100644 index 6bac04e..0000000 --- a/projects/core/src/instance/init/gryphn_dynamic_library.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "utils/gryphn_string.h" -#include "utils/gryphn_bool.h" - -typedef struct gnDynamicLibrary_t { - void* dllPtr; - gnBool isValid; -} gnDynamicLibrary; - -struct gnDynamicLibrary_t* gnLoadDynamicLibrary(const gnString path); -void gnUnloadDynamicLibrary(struct gnDynamicLibrary_t* dll); -void* gnLoadFunctionPtr(struct gnDynamicLibrary_t* dll, const char* name); - -#define gnLoadDLLFunction(dll, function, name) function = (typeof(function))gnLoadFunctionPtr(dll, name) diff --git a/projects/core/src/instance/init/gryphn_init.c b/projects/core/src/instance/init/gryphn_init.c index 994fe5f..d84f5b8 100644 --- a/projects/core/src/instance/init/gryphn_init.c +++ b/projects/core/src/instance/init/gryphn_init.c @@ -1,127 +1,126 @@ // #undef GN_UTILS_CPP #include "gryphn_init.h" #include -#include "gryphn_dynamic_library.h" // #include #include "stdbool.h" #include "stdio.h" -gnBool gnIsAPISupported(gnRenderingAPI api) { - int renderingAPICount = 0; - gnRenderingAPI* supportedRenderingAPIS = gnGetSupportedRenderingAPIs(&renderingAPICount); - for (int i = 0; i < renderingAPICount; i++) if (supportedRenderingAPIS[i] == api) return true; - return false; -} +// gnBool gnIsAPISupported(gnRenderingAPI api) { +// int renderingAPICount = 0; +// gnRenderingAPI* supportedRenderingAPIS = gnGetSupportedRenderingAPIs(&renderingAPICount); +// for (int i = 0; i < renderingAPICount; i++) if (supportedRenderingAPIS[i] == api) return true; +// return false; +// } -struct gnDynamicLibrary_t* gnLoadRenderingDLL(gnRenderingAPI renderingAPI) { - gnString libName = gnCreateEmptyString(); +// struct gnDynamicLibrary_t* gnLoadRenderingDLL(gnRenderingAPI renderingAPI) { +// gnString libName = gnCreateEmptyString(); - switch (renderingAPI) { - case GN_RENDERINGAPI_NONE: return NULL; - case GN_RENDERINGAPI_SOFTWARE: return NULL; - case GN_RENDERINGAPI_OPENGL: return NULL; - case GN_RENDERINGAPI_VULKAN: { - if (!gnIsAPISupported(GN_RENDERINGAPI_VULKAN)) return NULL; - libName = gnCreateString("GryphnVulkanImpl"); - break; - } - case GN_RENDERINGAPI_DIRECTX11: return NULL; - case GN_RENDERINGAPI_DIRECTX12: return NULL; - case GN_RENDERINGAPI_METAL: { - if (!gnIsAPISupported(GN_RENDERINGAPI_METAL)) return NULL; - libName = gnCreateString("GryphnMetalImpl"); - break; - } - } +// switch (renderingAPI) { +// case GN_RENDERINGAPI_NONE: return NULL; +// case GN_RENDERINGAPI_SOFTWARE: return NULL; +// case GN_RENDERINGAPI_OPENGL: return NULL; +// case GN_RENDERINGAPI_VULKAN: { +// if (!gnIsAPISupported(GN_RENDERINGAPI_VULKAN)) return NULL; +// libName = gnCreateString("GryphnVulkanImpl"); +// break; +// } +// case GN_RENDERINGAPI_DIRECTX11: return NULL; +// case GN_RENDERINGAPI_DIRECTX12: return NULL; +// case GN_RENDERINGAPI_METAL: { +// if (!gnIsAPISupported(GN_RENDERINGAPI_METAL)) return NULL; +// libName = gnCreateString("GryphnMetalImpl"); +// break; +// } +// } - return gnLoadDynamicLibrary(gnCombineStrings(gnCreateString("gryphn/rendering_apis/"), libName)); -} +// return gnLoadDynamicLibrary(gnCombineStrings(gnCreateString("gryphn/rendering_apis/"), libName)); +// } gnInstanceFunctions* gnLoadFunctions(gnInstanceHandle instance) { gnInstanceFunctions* functions = malloc(sizeof(gnInstanceFunctions)); - gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateInstance, "gnCreateInstanceFn"); - gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyInstance, "gnDestroyInstanceFn"); - gnLoadDLLFunction(instance->dynamicLib, functions->_gnGetPhysicalDevices, "gnGetPhysicalDevicesFn"); - gnLoadDLLFunction(instance->dynamicLib, functions->_gnQueueCanPresentToSurface, "gnQueueCanPresentToSurfaceFn"); - gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateOutputDevice, "gnCreateOutputDeviceFn"); - gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyOutputDevice, "gnDestroyOutputDeviceFn"); + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateInstance, "gnCreateInstanceFn"); + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyInstance, "gnDestroyInstanceFn"); + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnGetPhysicalDevices, "gnGetPhysicalDevicesFn"); + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnQueueCanPresentToSurface, "gnQueueCanPresentToSurfaceFn"); + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateOutputDevice, "gnCreateOutputDeviceFn"); + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyOutputDevice, "gnDestroyOutputDeviceFn"); - #ifdef GN_PLATFORM_LINUX - #ifdef GN_WINDOW_X11 - gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateX11WindowSurface, "gnCreateX11WindowSurfaceFn"); - #endif - #ifdef GN_WINDOW_WAYLAND - gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateWaylandWindowSurface, "gnCreateWaylandWindowSurfaceFn"); - #endif - #endif + // #ifdef GN_PLATFORM_LINUX + // #ifdef GN_WINDOW_X11 + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateX11WindowSurface, "gnCreateX11WindowSurfaceFn"); + // #endif + // #ifdef GN_WINDOW_WAYLAND + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateWaylandWindowSurface, "gnCreateWaylandWindowSurfaceFn"); + // #endif + // #endif - #ifdef GN_PLATFORM_WIN32 - gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateWin32WindowSurface, "gnCreateWin32WindowSurfaceFn"); - #endif + // #ifdef GN_PLATFORM_WIN32 + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateWin32WindowSurface, "gnCreateWin32WindowSurfaceFn"); + // #endif - #ifdef GN_PLATFORM_MACOS - gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateMacOSWindowSurface, "gnCreateMacOSWindowSurfaceFn"); - #endif + // #ifdef GN_PLATFORM_MACOS + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnCreateMacOSWindowSurface, "gnCreateMacOSWindowSurfaceFn"); + // #endif - gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyWindowSurface, "gnDestroyWindowSurfaceFn"); - gnLoadDLLFunction(instance->dynamicLib, functions->_gnGetSurfaceDetails, "gnGetSurfaceDetailsFn"); + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnDestroyWindowSurface, "gnDestroyWindowSurfaceFn"); + // gnLoadDLLFunction(instance->dynamicLib, functions->_gnGetSurfaceDetails, "gnGetSurfaceDetailsFn"); return functions; } void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFunctions_t* functions) { - gnLoadDLLFunction(lib, functions->_gnCreatePresentationQueue, "gnCreatePresentationQueueFn"); - gnLoadDLLFunction(lib, functions->_gnPresentationQueueGetImage, "gnPresentationQueueGetImageFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyPresentationQueue, "gnDestroyPresentationQueueFn"); - gnLoadDLLFunction(lib, functions->_gnCreateShaderModule, "gnCreateShaderModuleFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyShaderModule, "gnDestroyShaderModuleFn"); - gnLoadDLLFunction(lib, functions->_gnCreateRenderPassDescriptor, "gnCreateRenderPassDescriptorFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyRenderPassDescriptor, "gnDestroyRenderPassDescriptorFn"); - gnLoadDLLFunction(lib, functions->_gnCreateGraphicsPipeline, "gnCreateGraphicsPipelineFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn"); - gnLoadDLLFunction(lib, functions->_gnCreateFramebuffer, "gnCreateFramebufferFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyFramebuffer, "gnDestroyFramebufferFn"); - gnLoadDLLFunction(lib, functions->_gnCreateCommandPool, "gnCreateCommandPoolFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyCommandPool, "gnDestroyCommandPoolFn"); - gnLoadDLLFunction(lib, functions->_gnCreateSemaphore, "gnCreateSemaphoreFn"); - gnLoadDLLFunction(lib, functions->_gnDestroySemaphore, "gnDestroySemaphoreFn"); - gnLoadDLLFunction(lib, functions->_gnCreateBuffer, "gnCreateBufferFn"); - gnLoadDLLFunction(lib, functions->_gnBufferData, "gnBufferDataFn"); - gnLoadDLLFunction(lib, functions->_gnMapBuffer, "gnMapBufferFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyBuffer, "gnDestroyBufferFn"); - gnLoadDLLFunction(lib, functions->_gnCreateUniformPool, "gnCreateUniformPoolFn"); - gnLoadDLLFunction(lib, functions->_gnUniformPoolAllocateUniforms, "gnUniformPoolAllocateUniformsFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyUniformPool, "gnDestroyUniformPoolFn"); - gnLoadDLLFunction(lib, functions->_gnUpdateBufferUniform, "gnUpdateBufferUniformFn"); - gnLoadDLLFunction(lib, functions->_gnUpdateImageUniform, "gnUpdateImageUniformFn"); - gnLoadDLLFunction(lib, functions->_gnCreateTexture, "gnCreateTextureFn"); - gnLoadDLLFunction(lib, functions->_gnTextureData, "gnTextureDataFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyTexture, "gnDestroyTextureFn"); - gnLoadDLLFunction(lib, functions->_gnCreateFence, "gnCreateFenceFn"); - gnLoadDLLFunction(lib, functions->_gnSignalFence, "gnSignalFenceFn"); - gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn"); - gnLoadDLLFunction(lib, functions->_gnResetFence, "gnResetFenceFn"); - gnLoadDLLFunction(lib, functions->_gnDestroyFence, "gnDestroyFenceFn"); - gnLoadDLLFunction(lib, functions->_gnSubmit, "gnSubmitFn"); - gnLoadDLLFunction(lib, functions->_gnPresent, "gnPresentFn"); - gnLoadDLLFunction(lib, functions->_gnWaitForDevice, "gnWaitForDeviceFn"); + // gnLoadDLLFunction(lib, functions->_gnCreatePresentationQueue, "gnCreatePresentationQueueFn"); + // gnLoadDLLFunction(lib, functions->_gnPresentationQueueGetImage, "gnPresentationQueueGetImageFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyPresentationQueue, "gnDestroyPresentationQueueFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateShaderModule, "gnCreateShaderModuleFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyShaderModule, "gnDestroyShaderModuleFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateRenderPassDescriptor, "gnCreateRenderPassDescriptorFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyRenderPassDescriptor, "gnDestroyRenderPassDescriptorFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateGraphicsPipeline, "gnCreateGraphicsPipelineFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateFramebuffer, "gnCreateFramebufferFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyFramebuffer, "gnDestroyFramebufferFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateCommandPool, "gnCreateCommandPoolFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyCommandPool, "gnDestroyCommandPoolFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateSemaphore, "gnCreateSemaphoreFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroySemaphore, "gnDestroySemaphoreFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateBuffer, "gnCreateBufferFn"); + // gnLoadDLLFunction(lib, functions->_gnBufferData, "gnBufferDataFn"); + // gnLoadDLLFunction(lib, functions->_gnMapBuffer, "gnMapBufferFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyBuffer, "gnDestroyBufferFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateUniformPool, "gnCreateUniformPoolFn"); + // gnLoadDLLFunction(lib, functions->_gnUniformPoolAllocateUniforms, "gnUniformPoolAllocateUniformsFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyUniformPool, "gnDestroyUniformPoolFn"); + // gnLoadDLLFunction(lib, functions->_gnUpdateBufferUniform, "gnUpdateBufferUniformFn"); + // gnLoadDLLFunction(lib, functions->_gnUpdateImageUniform, "gnUpdateImageUniformFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateTexture, "gnCreateTextureFn"); + // gnLoadDLLFunction(lib, functions->_gnTextureData, "gnTextureDataFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyTexture, "gnDestroyTextureFn"); + // gnLoadDLLFunction(lib, functions->_gnCreateFence, "gnCreateFenceFn"); + // gnLoadDLLFunction(lib, functions->_gnSignalFence, "gnSignalFenceFn"); + // gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn"); + // gnLoadDLLFunction(lib, functions->_gnResetFence, "gnResetFenceFn"); + // gnLoadDLLFunction(lib, functions->_gnDestroyFence, "gnDestroyFenceFn"); + // gnLoadDLLFunction(lib, functions->_gnSubmit, "gnSubmitFn"); + // gnLoadDLLFunction(lib, functions->_gnPresent, "gnPresentFn"); + // gnLoadDLLFunction(lib, functions->_gnWaitForDevice, "gnWaitForDeviceFn"); } void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) { - gnLoadDLLFunction(lib, functions->_gnCommandPoolAllocateCommandBuffers, "gnCommandPoolAllocateCommandBuffersFn"); - gnLoadDLLFunction(lib, functions->_gnBeginCommandBuffer, "gnBeginCommandBufferFn"); - gnLoadDLLFunction(lib, functions->_gnResetCommandBuffer, "gnResetCommandBufferFn"); - gnLoadDLLFunction(lib, functions->_gnEndCommandBuffer, "gnEndCommandBufferFn"); - gnLoadDLLFunction(lib, functions->_gnCommandBeginRenderPass, "gnCommandBeginRenderPassFn"); - gnLoadDLLFunction(lib, functions->_gnCommandEndRenderPass, "gnCommandEndRenderPassFn"); - gnLoadDLLFunction(lib, functions->_gnCommandBindGraphicsPipeline, "gnCommandBindGraphicsPipelineFn"); - gnLoadDLLFunction(lib, functions->_gnCommandSetViewport, "gnCommandSetViewportFn"); - gnLoadDLLFunction(lib, functions->_gnCommandSetScissor, "gnCommandSetScissorFn"); - gnLoadDLLFunction(lib, functions->_gnCommandBindUniform, "gnCommandBindUniformFn"); - gnLoadDLLFunction(lib, functions->_gnCommandBindBuffer, "gnCommandBindBufferFn"); - gnLoadDLLFunction(lib, functions->_gnCommandPushConstant, "gnCommandPushConstantFn"); - gnLoadDLLFunction(lib, functions->_gnCommandDraw, "gnCommandDrawFn"); - gnLoadDLLFunction(lib, functions->_gnCommandDrawIndexed, "gnCommandDrawIndexedFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandPoolAllocateCommandBuffers, "gnCommandPoolAllocateCommandBuffersFn"); + // gnLoadDLLFunction(lib, functions->_gnBeginCommandBuffer, "gnBeginCommandBufferFn"); + // gnLoadDLLFunction(lib, functions->_gnResetCommandBuffer, "gnResetCommandBufferFn"); + // gnLoadDLLFunction(lib, functions->_gnEndCommandBuffer, "gnEndCommandBufferFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandBeginRenderPass, "gnCommandBeginRenderPassFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandEndRenderPass, "gnCommandEndRenderPassFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandBindGraphicsPipeline, "gnCommandBindGraphicsPipelineFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandSetViewport, "gnCommandSetViewportFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandSetScissor, "gnCommandSetScissorFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandBindUniform, "gnCommandBindUniformFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandBindBuffer, "gnCommandBindBufferFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandPushConstant, "gnCommandPushConstantFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandDraw, "gnCommandDrawFn"); + // gnLoadDLLFunction(lib, functions->_gnCommandDrawIndexed, "gnCommandDrawIndexedFn"); } diff --git a/projects/loader/CMakeLists.txt b/projects/loader/CMakeLists.txt new file mode 100644 index 0000000..b78d9a6 --- /dev/null +++ b/projects/loader/CMakeLists.txt @@ -0,0 +1,5 @@ +set(CMAKE_EXPORT_COMPILE_COMMANDS on) +project(GryphnLoader) + +file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS "src/*.c") +add_library(GryphnLoader STATIC ${SOURCE_FILES}) diff --git a/projects/loader/src/gryphn_loader.c b/projects/loader/src/gryphn_loader.c new file mode 100644 index 0000000..7a286f7 --- /dev/null +++ b/projects/loader/src/gryphn_loader.c @@ -0,0 +1,5 @@ +#include "stdio.h" + +void test_loader() { + printf("Loader works %i\n", 32); +} diff --git a/projects/loader/src/gryphn_loader.h b/projects/loader/src/gryphn_loader.h new file mode 100644 index 0000000..5aa59e4 --- /dev/null +++ b/projects/loader/src/gryphn_loader.h @@ -0,0 +1,3 @@ +#pragma once + +void test_loader(); diff --git a/projects/platform/platform_linux/gryphn_platform_linux.c b/projects/platform/platform_linux/gryphn_platform_linux.c index 1254898..2938e80 100644 --- a/projects/platform/platform_linux/gryphn_platform_linux.c +++ b/projects/platform/platform_linux/gryphn_platform_linux.c @@ -1,8 +1,6 @@ #ifdef GN_PLATFORM_LINUX #include "gryphn_platform_linux.h" -#include "core/gryphn_rendering_api.h" -#include "core/instance/init/gryphn_dynamic_library.h" -#include "dlfcn.h" +#include "gryphn_rendering_api.h" gnRenderingAPI renderingAPIs[2] = { GN_RENDERINGAPI_VULKAN, @@ -14,19 +12,4 @@ gnRenderingAPI* gnGetSupportedRenderingAPIs(int* count) { return renderingAPIs; } -struct gnDynamicLibrary_t* gnLoadDynamicLibrary(const gnString path) { - struct gnDynamicLibrary_t* dll = malloc(sizeof(struct gnDynamicLibrary_t)); - dll->dllPtr = dlopen(gnToCString(gnCombineStrings(path, ".so")), RTLD_LAZY), - dll->isValid = gnTrue; - if (dll->dllPtr == NULL) dll->isValid = gnFalse; - return dll; -} -void* gnLoadFunctionPtr(struct gnDynamicLibrary_t* dll, const char* name) { - if (dll->isValid == gnFalse) return NULL; - return dlsym(dll->dllPtr, name); -} -void gnUnloadDynamicLibrary(struct gnDynamicLibrary_t* dll) { - if (dll->isValid) dlclose(dll->dllPtr); -} - #endif