summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-27 06:01:27 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-27 06:01:27 +0000
commit87029a3f6979c79c65f9828bf886d01dcd94b936 (patch)
tree75e1a88d398d03bbd29258af6f20be6203238d8b /Graphics/GraphicsEngine
parentFixed BufferViewMtlImpl (diff)
downloadDiligentCore-87029a3f6979c79c65f9828bf886d01dcd94b936.tar.gz
DiligentCore-87029a3f6979c79c65f9828bf886d01dcd94b936.zip
Implemented D3D11 engine C interface (mostly)
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/interface/LoadEngineDll.h47
1 files changed, 27 insertions, 20 deletions
diff --git a/Graphics/GraphicsEngine/interface/LoadEngineDll.h b/Graphics/GraphicsEngine/interface/LoadEngineDll.h
index bd8a066e..9a65126e 100644
--- a/Graphics/GraphicsEngine/interface/LoadEngineDll.h
+++ b/Graphics/GraphicsEngine/interface/LoadEngineDll.h
@@ -30,10 +30,13 @@
/// \file
/// Helper function to load engine DLL on Windows
-#include <sstream>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "../../../Primitives/interface/CommonDefinitions.h"
#if PLATFORM_UNIVERSAL_WINDOWS
-# include "../../../Common/interface/StringTools.h"
+# include "../../../Common/interface/StringTools.hpp"
#endif
#ifndef NOMINMAX
@@ -41,53 +44,57 @@
#endif
#include <Windows.h>
-namespace Diligent
-{
+DILIGENT_BEGIN_NAMESPACE(Diligent)
inline FARPROC LoadEngineDll(const char* EngineName, const char* GetFactoryFuncName)
{
- std::string LibName = EngineName;
+ const size_t StringBufferSize = 4096;
+ char* LibName = (char*)malloc(StringBufferSize);
+ FARPROC GetFactoryFunc = NULL;
+ HMODULE hModule = NULL;
+ // clang-format off
#if _WIN64
- LibName += "_64";
+ const char* Arch = "_64";
#else
- LibName += "_32";
+ const char* Arch = "_32";
#endif
#ifdef _DEBUG
- LibName += "d";
+ const char* Conf = "d";
#else
- LibName += "r";
+ const char* Conf = "r";
#endif
- LibName += ".dll";
+ sprintf_s(LibName, StringBufferSize, "%s%s%s.dll", EngineName, Conf, Arch);
#if PLATFORM_WIN32
- auto hModule = LoadLibraryA(LibName.c_str());
+ hModule = LoadLibraryA(LibName);
#elif PLATFORM_UNIVERSAL_WINDOWS
- auto hModule = LoadPackagedLibrary(WidenString(LibName).c_str(), 0);
+ hModule = LoadPackagedLibrary(WidenString(LibName).c_str(), 0);
#else
# error Unexpected platform
#endif
+ // clang-format on
if (hModule == NULL)
{
- std::stringstream ss;
- ss << "Failed to load " << LibName << " library.\n";
- OutputDebugStringA(ss.str().c_str());
+ printf("Failed to load %s library.\n", LibName);
+ OutputDebugStringA("Failed to load engine DLL");
+ free(LibName);
return NULL;
}
- auto GetFactoryFunc = GetProcAddress(hModule, GetFactoryFuncName);
+ GetFactoryFunc = GetProcAddress(hModule, GetFactoryFuncName);
if (GetFactoryFunc == NULL)
{
- std::stringstream ss;
- ss << "Failed to load " << GetFactoryFuncName << " function from " << LibName << " library.\n";
- OutputDebugStringA(ss.str().c_str());
+ printf("Failed to load %s function from %s library.\n", GetFactoryFuncName, LibName);
+ OutputDebugStringA("Failed to load engine factory function from library");
FreeLibrary(hModule);
}
+ free(LibName);
return GetFactoryFunc;
}
-} // namespace Diligent
+DILIGENT_END_NAMESPACE // namespace Diligent