diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-12-07 22:17:17 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-12-07 22:17:17 +0000 |
| commit | 983e76d57b2748796b62b114446f9337f3709ff5 (patch) | |
| tree | d1de3a22fc28e0b84b70c6b28677d5d70757a91f /Graphics/GraphicsEngineOpenGL | |
| parent | Fixed run_tests.bat (diff) | |
| download | DiligentCore-983e76d57b2748796b62b114446f9337f3709ff5.tar.gz DiligentCore-983e76d57b2748796b62b114446f9337f3709ff5.zip | |
Reworked API Unit test to use run-time DLL loading to avoid apparent issue with missing Vulkan library on appveyor; improved implementation of DLL loading on Windows
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
| -rw-r--r-- | Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h | 53 |
1 files changed, 10 insertions, 43 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h b/Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h index 7d06f16b..3f8baf3f 100644 --- a/Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h +++ b/Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h @@ -37,18 +37,19 @@ #if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || (PLATFORM_WIN32 && !defined(_MSC_VER)) - // https://gcc.gnu.org/wiki/Visibility # define API_QUALIFIER __attribute__((visibility("default"))) - #elif PLATFORM_WIN32 - # define API_QUALIFIER - #else # error Unsupported platform #endif +#if ENGINE_DLL && PLATFORM_WIN32 && defined(_MSC_VER) +# include "../../GraphicsEngine/interface/LoadEngineDll.h" +# define EXPLICITLY_LOAD_ENGINE_GL_DLL 1 +#endif + namespace Diligent { @@ -72,49 +73,15 @@ public: }; -#if ENGINE_DLL && PLATFORM_WIN32 && defined(_MSC_VER) - -# define EXPLICITLY_LOAD_ENGINE_GL_DLL 1 +#if EXPLICITLY_LOAD_ENGINE_GL_DLL -typedef IEngineFactoryOpenGL* (*GetEngineFactoryOpenGLType)(); +using GetEngineFactoryOpenGLType = IEngineFactoryOpenGL* (*)(); static bool LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGLType& GetFactoryFunc) { - GetFactoryFunc = nullptr; - std::string LibName = "GraphicsEngineOpenGL_"; - -# if _WIN64 - LibName += "64"; -# else - LibName += "32"; -# endif - -# ifdef _DEBUG - LibName += "d"; -# else - LibName += "r"; -# endif - - LibName += ".dll"; - auto hModule = LoadLibraryA(LibName.c_str()); - if (hModule == NULL) - { - std::stringstream ss; - ss << "Failed to load " << LibName << " library.\n"; - OutputDebugStringA(ss.str().c_str()); - return false; - } - - GetFactoryFunc = reinterpret_cast<GetEngineFactoryOpenGLType>(GetProcAddress(hModule, "GetEngineFactoryOpenGL")); - if (GetFactoryFunc == NULL) - { - std::stringstream ss; - ss << "Failed to load GetEngineFactoryOpenGL() from " << LibName << " library.\n"; - OutputDebugStringA(ss.str().c_str()); - FreeLibrary(hModule); - return false; - } - return true; + auto ProcAddress = LoadEngineDll("GraphicsEngineOpenGL", "GetEngineFactoryOpenGL"); + GetFactoryFunc = reinterpret_cast<GetEngineFactoryOpenGLType>(ProcAddress); + return GetFactoryFunc != nullptr; } #else |
