diff --git a/MobileGL/Init.cpp b/MobileGL/Init.cpp index 308f1fb1..5038892f 100644 --- a/MobileGL/Init.cpp +++ b/MobileGL/Init.cpp @@ -14,13 +14,12 @@ #include namespace MobileGL { - void MG_Initialize() { + void MG_Initialize(Bool loadExternalLibraries) { MG_Util::Debug::InitFile(); MGLOG_I("Initializing MobileGL..."); MG_State::Init(); MGLOG_D("MobileGL State initialized"); - // return; - MG_Backend::Init(); + MG_Backend::Init(loadExternalLibraries); MGLOG_D("MobileGL Backend initialized"); MG_Impl::Init(); MGLOG_D("MobileGL Implementation initialized"); diff --git a/MobileGL/Init.h b/MobileGL/Init.h index 39353ad6..eb6a2207 100644 --- a/MobileGL/Init.h +++ b/MobileGL/Init.h @@ -9,6 +9,6 @@ #include "Includes.h" namespace MobileGL { - void MG_Initialize(); + void MG_Initialize(Bool loadExternalLibraries = true); void MG_Destroy(); } // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Backend/Backends.h b/MobileGL/MG_Backend/Backends.h index 10b9a3d1..62c0b1cc 100644 --- a/MobileGL/MG_Backend/Backends.h +++ b/MobileGL/MG_Backend/Backends.h @@ -85,6 +85,6 @@ namespace MobileGL { }; } // namespace DirectGLES - void Init(); + void Init(Bool loadExternalLibraries); } // namespace MG_Backend } // namespace MobileGL diff --git a/MobileGL/MG_Backend/Init.cpp b/MobileGL/MG_Backend/Init.cpp index 58125171..e22a6209 100644 --- a/MobileGL/MG_Backend/Init.cpp +++ b/MobileGL/MG_Backend/Init.cpp @@ -53,7 +53,7 @@ namespace MobileGL { #endif } - void Init() { + void Init(Bool loadExternalLibraries) { MGLOG_D("Initializing MobileGL Backend..."); #if MOBILEGL_BACKEND == MOBILEGL_BACKEND_DILIGENT @@ -73,6 +73,12 @@ namespace MobileGL { MG_Config::RendererInfoPtr = MakeUnique(Unknown::RendererInfoUnknown); #endif + if (!loadExternalLibraries) { + MGLOG_W("Skipping external library loading. Calling functions that call external libraries may cause " + "crashes."); + return; + } + InitSpecificBackendLibs(); LogBackendInfo(); } diff --git a/MobileGL/MG_Benchmark/Buffer/BufferBench.cpp b/MobileGL/MG_Benchmark/Buffer/BufferBench.cpp index 9797c698..59d8ee5b 100644 --- a/MobileGL/MG_Benchmark/Buffer/BufferBench.cpp +++ b/MobileGL/MG_Benchmark/Buffer/BufferBench.cpp @@ -60,7 +60,7 @@ static void BM_CreateBufferObjectsAndBindBuffer(benchmark::State& state) { BENCHMARK(BM_CreateBufferObjectsAndBindBuffer)->Unit(benchmark::kMillisecond)->UseRealTime(); static void BM_DeleteBufferObjects(benchmark::State& state) { - MG_Initialize(); + MG_Initialize(false); std::vector buffers(BUFFER_COUNT); for (auto _ : state) { @@ -178,7 +178,7 @@ static void BM_UpdateDataPartially(benchmark::State& state) { BENCHMARK(BM_UpdateDataPartially)->Unit(benchmark::kMillisecond)->UseRealTime(); int main(int argc, char** argv) { - MG_Initialize(); + MG_Initialize(false); benchmark ::MaybeReenterWithoutASLR(argc, argv); char arg0_default[] = "benchmark"; char* args_default = reinterpret_cast(arg0_default); diff --git a/MobileGL/MG_Benchmark/Program/ProgramBench.cpp b/MobileGL/MG_Benchmark/Program/ProgramBench.cpp index fc42fd63..8901c8e1 100644 --- a/MobileGL/MG_Benchmark/Program/ProgramBench.cpp +++ b/MobileGL/MG_Benchmark/Program/ProgramBench.cpp @@ -220,7 +220,7 @@ static void BM_CompileAndLink(benchmark::State& state) { BENCHMARK(BM_CompileAndLink)->Unit(benchmark::kMillisecond); int main(int argc, char** argv) { - MG_Initialize(); + MG_Initialize(false); benchmark ::MaybeReenterWithoutASLR(argc, argv); char arg0_default[] = "benchmark"; char* args_default = reinterpret_cast(arg0_default); diff --git a/MobileGL/MG_Test/Buffer/BufferTest.cpp b/MobileGL/MG_Test/Buffer/BufferTest.cpp index a9bd9053..34acc61d 100644 --- a/MobileGL/MG_Test/Buffer/BufferTest.cpp +++ b/MobileGL/MG_Test/Buffer/BufferTest.cpp @@ -18,7 +18,7 @@ using namespace MobileGL; class BufferTest : public ::testing::Test { protected: - void SetUp() override { MobileGL::MG_Initialize(); } + void SetUp() override { MobileGL::MG_Initialize(false); } void TearDown() override {} }; diff --git a/MobileGL/MG_Test/Program/ProgramTest.cpp b/MobileGL/MG_Test/Program/ProgramTest.cpp index 297f3859..8e7b3c76 100644 --- a/MobileGL/MG_Test/Program/ProgramTest.cpp +++ b/MobileGL/MG_Test/Program/ProgramTest.cpp @@ -17,7 +17,7 @@ using namespace MobileGL::MG_Impl::GLImpl; class ProgramTest : public ::testing::Test { protected: - void SetUp() override { MobileGL::MG_Initialize(); } + void SetUp() override { MobileGL::MG_Initialize(false); } void TearDown() override {} }; diff --git a/MobileGL/MG_Test/Program/ProgramUtilTest.cpp b/MobileGL/MG_Test/Program/ProgramUtilTest.cpp index 328579b9..35c4f8a1 100644 --- a/MobileGL/MG_Test/Program/ProgramUtilTest.cpp +++ b/MobileGL/MG_Test/Program/ProgramUtilTest.cpp @@ -18,7 +18,7 @@ using namespace MobileGL; class ProgramUtilTest : public ::testing::Test { protected: - void SetUp() override { MobileGL::MG_Initialize(); } + void SetUp() override { MobileGL::MG_Initialize(false); } void TearDown() override {} }; diff --git a/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp b/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp index ba423020..5aa68425 100644 --- a/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp +++ b/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp @@ -32,7 +32,7 @@ protected: return vbo; } - void SetUp() override { MobileGL::MG_Initialize(); } + void SetUp() override { MobileGL::MG_Initialize(false); } void TearDown() override {} };