From de15037e97797f93e33b69a59f5dcbda5f22bd6c Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Tue, 9 Apr 2024 18:18:39 +0200 Subject: [PATCH 1/4] Add null runner --- CMakeLists.txt | 5 ++ CMakePresets.json | 11 ++++- hello_imgui_cmake/hello_imgui_build_lib.cmake | 12 +++++ .../backend_impls/abstract_runner.cpp | 5 ++ .../null_window_helper.h | 48 +++++++++++++++++++ .../internal/backend_impls/null_config.h | 29 +++++++++++ .../internal/backend_impls/rendering_null.cpp | 29 +++++++++++ .../internal/backend_impls/rendering_null.h | 11 +++++ .../internal/backend_impls/runner_factory.cpp | 9 ++++ .../internal/backend_impls/runner_null.h | 47 ++++++++++++++++++ src/hello_imgui/runner_params.h | 2 + .../hello_imgui_demodocking.main.cpp | 2 +- 12 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 src/hello_imgui/internal/backend_impls/backend_window_helper/null_window_helper.h create mode 100644 src/hello_imgui/internal/backend_impls/null_config.h create mode 100644 src/hello_imgui/internal/backend_impls/rendering_null.cpp create mode 100644 src/hello_imgui/internal/backend_impls/rendering_null.h create mode 100644 src/hello_imgui/internal/backend_impls/runner_null.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 65ea80a2..803c30de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,12 +82,17 @@ option(HELLOIMGUI_ADD_APP_WITH_INSTALL "Add cmake install() instructions with he # Platform backends: option(HELLOIMGUI_USE_GLFW3 "Use Glfw3 as a platform backend" OFF) option(HELLOIMGUI_USE_SDL2 "Use Sdl2 as a platform backend" OFF) +option(HELLOIMGUI_USE_NULL "Null platform backend" OFF) # for testing and remote rendering # Rendering backends option(HELLOIMGUI_HAS_OPENGL3 "Use OpenGL3 as a rendering backend" OFF) option(HELLOIMGUI_HAS_METAL "Use Metal as a rendering backend" OFF) option(HELLOIMGUI_HAS_VULKAN "Use Vulkan as a rendering backend" OFF) option(HELLOIMGUI_HAS_DIRECTX11 "Use DirectX11 as a rendering backend" OFF) option(HELLOIMGUI_HAS_DIRECTX12 "Use DirectX12 as a rendering backend" OFF) +option(HELLOIMGUI_HAS_NULL "Null rendering backend" OFF) # for testing and remote rendering + +# Null backend: useful for testing, or for remote rendering (will set both rendering and platform backends to null) +option(HELLOIMGUI_NULL_BACKEND "Use Null rendering/platform backend" OFF) # # do not remove this line (used by the script that generates the documentation) diff --git a/CMakePresets.json b/CMakePresets.json index 3b6a2c0a..f96aafca 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -23,11 +23,20 @@ "cacheVariables": { "HELLOIMGUI_USE_SDL2": "ON", "HELLOIMGUI_USE_GLFW3": "ON", + "HELLOIMGUI_USE_NULL": "ON", "HELLOIMGUI_HAS_OPENGL3": "ON", "HELLOIMGUI_HAS_METAL": "ON", "HELLOIMGUI_HAS_VULKAN": "ON", "HELLOIMGUI_HAS_DIRECTX11": "ON", - "HELLOIMGUI_HAS_DIRECTX12": "ON" + "HELLOIMGUI_HAS_DIRECTX12": "ON", + "HELLOIMGUI_HAS_NULL": "ON" + } + }, + { + "name": "build_null_backend", + "description": "Build with null backend.", + "cacheVariables": { + "HELLOIMGUI_NULL_BACKEND": "ON" } }, { diff --git a/hello_imgui_cmake/hello_imgui_build_lib.cmake b/hello_imgui_cmake/hello_imgui_build_lib.cmake index 74d5f2a4..f53da250 100644 --- a/hello_imgui_cmake/hello_imgui_build_lib.cmake +++ b/hello_imgui_cmake/hello_imgui_build_lib.cmake @@ -34,6 +34,7 @@ function(him_back_available_platform_backends out_var) set(${out_var} HELLOIMGUI_USE_SDL2 HELLOIMGUI_USE_GLFW3 + HELLOIMGUI_USE_NULL PARENT_SCOPE) endfunction() @@ -44,10 +45,15 @@ function(him_back_available_rendering_backends out_var) HELLOIMGUI_HAS_VULKAN HELLOIMGUI_HAS_DIRECTX11 HELLOIMGUI_HAS_DIRECTX12 + HELLOIMGUI_HAS_NULL PARENT_SCOPE) endfunction() function(him_back_parse_legacy_combinations) + if(HELLOIMGUI_NULL_BACKEND) + set(HELLOIMGUI_USE_NULL ON CACHE BOOL "" FORCE) + set(HELLOIMGUI_HAS_NULL ON CACHE BOOL "" FORCE) + endif() if(HELLOIMGUI_USE_SDL_OPENGL3) message(WARNING " HELLOIMGUI_USE_SDL_OPENGL3 is deprecated, @@ -1156,6 +1162,9 @@ function(him_main_add_hello_imgui_library) if (HELLOIMGUI_USE_GLFW3) him_use_glfw3_backend(${HELLOIMGUI_TARGET}) endif() + if (HELLOIMGUI_USE_NULL) + target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_USE_NULL) + endif() if (HELLOIMGUI_HAS_OPENGL3) him_has_opengl3(${HELLOIMGUI_TARGET}) @@ -1172,6 +1181,9 @@ function(him_main_add_hello_imgui_library) if (HELLOIMGUI_HAS_DIRECTX12) him_has_directx12(${HELLOIMGUI_TARGET}) endif() + if (HELLOIMGUI_HAS_NULL) + target_compile_definitions(${HELLOIMGUI_TARGET} PUBLIC HELLOIMGUI_HAS_NULL) + endif() him_add_apple_options() him_add_linux_options() diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp index 98c11e38..474eff16 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp @@ -52,6 +52,7 @@ #include "rendering_vulkan.h" #include "rendering_dx11.h" #include "rendering_dx12.h" +#include "rendering_null.h" // // NOTE: AbstractRunner should *not* care in any case of: @@ -578,6 +579,10 @@ void AbstractRunner::InitRenderBackendCallbacks() IM_ASSERT(false && "DirectX12 backend is not available!"); #endif } + else if (params.rendererBackendType == RendererBackendType::Null) + { + mRenderingBackendCallbacks = CreateBackendCallbacks_Null(); + } else { fprintf(stderr, "Missing rendering backend! %s\n", gMissingBackendErrorMessage.c_str()); diff --git a/src/hello_imgui/internal/backend_impls/backend_window_helper/null_window_helper.h b/src/hello_imgui/internal/backend_impls/backend_window_helper/null_window_helper.h new file mode 100644 index 00000000..fac9bc92 --- /dev/null +++ b/src/hello_imgui/internal/backend_impls/backend_window_helper/null_window_helper.h @@ -0,0 +1,48 @@ +#pragma once +#ifdef HELLOIMGUI_USE_NULL + +#include "backend_window_helper.h" +#include "hello_imgui/internal/backend_impls/null_config.h" +#include + +#ifdef _WIN32 +#ifdef CreateWindow +#undef CreateWindow +#endif +#endif + + +namespace HelloImGui { namespace BackendApi +{ + class NullWindowHelper: public IBackendWindowHelper + { + // Note: this is a fake class, it has no member + // It is only a class in order to enforce a consistent API between backends. + public: + WindowPointer CreateWindow(AppWindowParams &appWindowParams, const BackendOptions& backendOptions) override { + return nullptr; + } + + std::vector GetMonitorsWorkAreas() override { return NullConfig::GetMonitorsWorkAreas();} + + bool IsWindowIconified(WindowPointer window) override { return false; } + void RaiseWindow(WindowPointer window) override {} + + ScreenBounds GetWindowBounds(WindowPointer window) override { return {}; } + void SetWindowBounds(WindowPointer window, ScreenBounds windowBounds) override {} + + void WaitForEventTimeout(double timeout_seconds) override { + std::this_thread::sleep_for(std::chrono::milliseconds((int)(timeout_seconds * 1000))); + } + + ImVec2 GetWindowScaleFactor(WindowPointer window) override { return NullConfig::GetWindowScaleFactor(); } + float GetWindowSizeDpiScaleFactor(WindowPointer window) override { return NullConfig::GetWindowSizeDpiScaleFactor(); } + + void HideWindow(WindowPointer window) override {} + void ShowWindow(WindowPointer window) override {} + bool IsWindowHidden(WindowPointer window) override { return false; } + + }; +}} // namespace HelloImGui { namespace BackendApi + +#endif // #ifdef HELLOIMGUI_USE_NULL diff --git a/src/hello_imgui/internal/backend_impls/null_config.h b/src/hello_imgui/internal/backend_impls/null_config.h new file mode 100644 index 00000000..ff5bf905 --- /dev/null +++ b/src/hello_imgui/internal/backend_impls/null_config.h @@ -0,0 +1,29 @@ +#pragma once + +#include "hello_imgui/screen_bounds.h" +#include "imgui.h" +#include + +namespace HelloImGui +{ +namespace NullConfig +{ + ScreenBounds GetScreenBounds() + { + ScreenBounds bounds; + bounds.size = {1920, 1080}; + bounds.position = {0, 0}; + return {bounds}; + } + + std::vector GetMonitorsWorkAreas() + { + return {GetScreenBounds()}; + } + + ImVec2 GetWindowScaleFactor() { return {1.f, 1.f}; } + float GetWindowSizeDpiScaleFactor() { return 1.f; } + +} + +} \ No newline at end of file diff --git a/src/hello_imgui/internal/backend_impls/rendering_null.cpp b/src/hello_imgui/internal/backend_impls/rendering_null.cpp new file mode 100644 index 00000000..b0d28c2d --- /dev/null +++ b/src/hello_imgui/internal/backend_impls/rendering_null.cpp @@ -0,0 +1,29 @@ +#ifdef HELLOIMGUI_HAS_NULL +#include "rendering_null.h" + + +namespace HelloImGui +{ + RenderingCallbacksPtr CreateBackendCallbacks_Null() + { + auto callbacks = std::make_shared(); + + callbacks->Impl_NewFrame_3D = [] {}; + + callbacks->Impl_RenderDrawData_To_3D = [] {}; + + callbacks->Impl_ScreenshotRgb_3D = []() { return ImageBuffer{}; }; + + callbacks->Impl_Frame_3D_ClearColor = [](ImVec4) {}; + + callbacks->Impl_Shutdown_3D = [] {}; + + callbacks->Impl_CreateFontTexture = [] {}; + callbacks->Impl_DestroyFontTexture = [] {}; + + return callbacks; + } + +} + +#endif \ No newline at end of file diff --git a/src/hello_imgui/internal/backend_impls/rendering_null.h b/src/hello_imgui/internal/backend_impls/rendering_null.h new file mode 100644 index 00000000..c0527fbc --- /dev/null +++ b/src/hello_imgui/internal/backend_impls/rendering_null.h @@ -0,0 +1,11 @@ +#pragma once +#ifdef HELLOIMGUI_HAS_NULL + +#include "hello_imgui/internal/backend_impls/rendering_callbacks.h" + +namespace HelloImGui +{ + RenderingCallbacksPtr CreateBackendCallbacks_Null(); +} + +#endif \ No newline at end of file diff --git a/src/hello_imgui/internal/backend_impls/runner_factory.cpp b/src/hello_imgui/internal/backend_impls/runner_factory.cpp index d4572a85..e49394a3 100644 --- a/src/hello_imgui/internal/backend_impls/runner_factory.cpp +++ b/src/hello_imgui/internal/backend_impls/runner_factory.cpp @@ -3,6 +3,7 @@ #include "hello_imgui/internal/backend_impls/runner_glfw3.h" #include "hello_imgui/internal/backend_impls/runner_sdl2.h" #include "hello_imgui/internal/backend_impls/runner_sdl_emscripten.h" +#include "hello_imgui/internal/backend_impls/runner_null.h" namespace HelloImGui { @@ -15,6 +16,8 @@ void ChooseBackendTypesIfSelectedAsFirstAvailable(RunnerParams* runnerParams) runnerParams->platformBackendType = PlatformBackendType::Glfw; #elif defined(HELLOIMGUI_USE_SDL2) runnerParams->platformBackendType = PlatformBackendType::Sdl; + #elif defined(HELLOIMGUI_USE_NULL) + runnerParams->platformBackendType = PlatformBackendType::Null; #endif } @@ -30,6 +33,8 @@ void ChooseBackendTypesIfSelectedAsFirstAvailable(RunnerParams* runnerParams) runnerParams->rendererBackendType = RendererBackendType::DirectX11; #elif defined(HELLOIMGUI_HAS_DIRECTX12) runnerParams->rendererBackendType = RendererBackendType::DirectX12; + #elif defined(HELLOIMGUI_HAS_NULL) + runnerParams->rendererBackendType = RendererBackendType::Null; #endif } } @@ -56,6 +61,10 @@ std::unique_ptr FactorRunner(RunnerParams& params) return nullptr; #endif } + else if (params.platformBackendType == PlatformBackendType::Null) + { + return std::make_unique(params); + } else return nullptr; } diff --git a/src/hello_imgui/internal/backend_impls/runner_null.h b/src/hello_imgui/internal/backend_impls/runner_null.h new file mode 100644 index 00000000..4e8314c6 --- /dev/null +++ b/src/hello_imgui/internal/backend_impls/runner_null.h @@ -0,0 +1,47 @@ +#pragma once +#ifdef HELLOIMGUI_USE_NULL +#include "hello_imgui/internal/backend_impls/abstract_runner.h" +#include "hello_imgui/internal/backend_impls/backend_window_helper/null_window_helper.h" +#include "hello_imgui/internal/backend_impls/null_config.h" + + +namespace HelloImGui +{ + class RunnerNull : public AbstractRunner + { + public: + RunnerNull(RunnerParams & runnerParams): AbstractRunner(runnerParams) { + mBackendWindowHelper = std::make_unique(); + } + virtual ~RunnerNull() = default; + + protected: + // + // Methods related to the platform backend (SDL, Glfw, ...) + // + void Impl_InitPlatformBackend() override { + auto size = NullConfig::GetScreenBounds().size; + ImGui::GetIO().DisplaySize = ImVec2((float)size[0], (float)size[1]); + } + void Impl_CreateWindow() override {} + void Impl_PollEvents() override {} + void Impl_NewFrame_PlatformBackend() override {} + void Impl_UpdateAndRenderAdditionalPlatformWindows() override {} + void Impl_Cleanup() override {} + void Impl_SwapBuffers() override {} + void Impl_SetWindowIcon() override {} + void Impl_LinkPlatformAndRenderBackends() override {} + +#ifdef HELLOIMGUI_HAS_OPENGL + public: + void Impl_Select_Gl_Version() override {} + void Impl_InitGlLoader() override {} + std::string Impl_GlslVersion() const override { return "";} + void Impl_CreateGlContext() override {} +#endif + + }; + +} // namespace HelloImGui + +#endif // #ifdef HELLOIMGUI_USE_NULL diff --git a/src/hello_imgui/runner_params.h b/src/hello_imgui/runner_params.h index 58c14ed6..a7ea9c99 100644 --- a/src/hello_imgui/runner_params.h +++ b/src/hello_imgui/runner_params.h @@ -25,6 +25,7 @@ enum class PlatformBackendType FirstAvailable, Glfw, Sdl, + Null }; // Rendering backend type (OpenGL3, Metal, Vulkan, DirectX11, DirectX12) @@ -37,6 +38,7 @@ enum class RendererBackendType Vulkan, DirectX11, DirectX12, + Null }; // @@md diff --git a/src/hello_imgui_demos/hello_imgui_demodocking/hello_imgui_demodocking.main.cpp b/src/hello_imgui_demos/hello_imgui_demodocking/hello_imgui_demodocking.main.cpp index f890013a..f2422984 100644 --- a/src/hello_imgui_demos/hello_imgui_demodocking/hello_imgui_demodocking.main.cpp +++ b/src/hello_imgui_demos/hello_imgui_demodocking/hello_imgui_demodocking.main.cpp @@ -662,7 +662,7 @@ int main(int, char**) runnerParams.imGuiWindowParams.menuAppTitle = "Docking Demo"; runnerParams.appWindowParams.windowGeometry.size = {1200, 1000}; runnerParams.appWindowParams.restorePreviousGeometry = true; - + // Our application uses a borderless window, but is movable/resizable runnerParams.appWindowParams.borderless = true; runnerParams.appWindowParams.borderlessMovable = true; From b9f680161616939263b4a7cd254018bf1de6cccd Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Tue, 9 Apr 2024 18:41:29 +0200 Subject: [PATCH 2/4] Improve FrameRate stats --- src/hello_imgui/impl/hello_imgui.cpp | 41 +++++++++++++------ .../backend_impls/abstract_runner.cpp | 28 ++++++++----- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/hello_imgui/impl/hello_imgui.cpp b/src/hello_imgui/impl/hello_imgui.cpp index d19b6e14..aec1a945 100644 --- a/src/hello_imgui/impl/hello_imgui.cpp +++ b/src/hello_imgui/impl/hello_imgui.cpp @@ -152,27 +152,42 @@ namespace ChronoShenanigans } -float FrameRate(float durationForMean) +static std::deque gFrameTimes; + +void _UpdateFrameRateStats() { - static std::deque times; float now = ChronoShenanigans::ClockSeconds(); - times.push_back(now); - if (times.size() <= 1) + gFrameTimes.push_back(now); + + size_t maxFrameCount = 300; + while (gFrameTimes.size() > maxFrameCount) + gFrameTimes.pop_front(); +}; + +float FrameRate(float durationForMean) +{ + if (gFrameTimes.size() <= 1) return 0.f; - while (true) + float lastFrameTime = gFrameTimes.back(); + int lastFrameIdx = (int)gFrameTimes.size() - 1; + + // Go back in frame times to find the first frame that is not too old + int i = (int)gFrameTimes.size() - 1; + while (i > 0) { - float firstTime = times.front(); - float age = now - firstTime; - if ((age > durationForMean) && (times.size() >= 3)) - times.pop_front(); - else + if (lastFrameTime - gFrameTimes[i] > durationForMean) break; + --i; } + if (i == lastFrameIdx) + return 0.f; + // printf("i=%d, lastFrameIdx=%d\n", i, lastFrameIdx); - float totalTime = times.back() - times.front(); - int nbFrames = (int)times.size(); - float fps = 1.f / (totalTime / (float) (nbFrames - 1)); + // Compute the mean frame rate + float totalTime = lastFrameTime - gFrameTimes[i]; + int nbFrames = lastFrameIdx - i; + float fps = (float)nbFrames / totalTime; return fps; } diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp index 474eff16..0c545d3a 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp @@ -742,6 +742,8 @@ void AbstractRunner::RenderGui() } +void _UpdateFrameRateStats(); // See hello_imgui.cpp + void AbstractRunner::CreateFramesAndRender() { // Notes: @@ -765,11 +767,17 @@ void AbstractRunner::CreateFramesAndRender() // any user callback (which may call python functions) // - - // `true_gil` is a synonym for "true" (whenever using Python or not using Python) - // (it is here only to make the code more readable) - constexpr bool true_gil = true; + // `foldable_region` is a synonym for "true" (whenever using Python or not using Python) + // (it is here only to make the code more readable, and to enable to collapse blocks of code) + constexpr bool foldable_region = true; + + if (foldable_region) // Update frame rate stats + { + _UpdateFrameRateStats(); + // printf("Render frame %i, fps=%.1f\n", mIdxFrame, HelloImGui::FrameRate()); + } - if (true_gil) // basic layout checks + if (foldable_region) // basic layout checks { // SCOPED_RELEASE_GIL_ON_MAIN_THREAD start SCOPED_RELEASE_GIL_ON_MAIN_THREAD; @@ -785,7 +793,7 @@ void AbstractRunner::CreateFramesAndRender() #endif } // SCOPED_RELEASE_GIL_ON_MAIN_THREAD end - if (true) // Register tests + if (foldable_region) // Register tests { #ifdef HELLOIMGUI_WITH_TEST_ENGINE // This block calls a user callback, so it cannot be inside SCOPED_RELEASE_GIL_ON_MAIN_THREAD @@ -800,7 +808,7 @@ void AbstractRunner::CreateFramesAndRender() #endif } - if (true_gil) // handle window size and position on first frames + if (foldable_region) // handle window size and position on first frames { // SCOPED_RELEASE_GIL_ON_MAIN_THREAD start SCOPED_RELEASE_GIL_ON_MAIN_THREAD; @@ -865,7 +873,7 @@ void AbstractRunner::CreateFramesAndRender() } } // SCOPED_RELEASE_GIL_ON_MAIN_THREAD end - if(true_gil) // Handle idling + if(foldable_region) // Handle idling { // SCOPED_RELEASE_GIL_ON_MAIN_THREAD start SCOPED_RELEASE_GIL_ON_MAIN_THREAD; @@ -889,7 +897,7 @@ void AbstractRunner::CreateFramesAndRender() #endif } // SCOPED_RELEASE_GIL_ON_MAIN_THREAD end - if (true_gil) // Load additional fonts during execution + if (foldable_region) // Load additional fonts during execution { if (params.callbacks.LoadAdditionalFonts != nullptr) { @@ -909,7 +917,7 @@ void AbstractRunner::CreateFramesAndRender() if (params.callbacks.PreNewFrame) params.callbacks.PreNewFrame(); - if (true_gil) // New Frame / Rendering and Platform Backend (not ImGui) + if (foldable_region) // New Frame / Rendering and Platform Backend (not ImGui) { // SCOPED_RELEASE_GIL_ON_MAIN_THREAD start SCOPED_RELEASE_GIL_ON_MAIN_THREAD; @@ -963,7 +971,7 @@ void AbstractRunner::CreateFramesAndRender() if (params.callbacks.BeforeImGuiRender) params.callbacks.BeforeImGuiRender(); - if (true_gil) // Render and Swap + if (foldable_region) // Render and Swap { // SCOPED_RELEASE_GIL_ON_MAIN_THREAD start SCOPED_RELEASE_GIL_ON_MAIN_THREAD; From 973036b2969ebe8b39eff98d4c7a924f3ae5272f Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Wed, 10 Apr 2024 14:55:10 +0200 Subject: [PATCH 3/4] fix runnerFactory / use HELLOIMGUI_USE_NULL --- src/hello_imgui/internal/backend_impls/runner_factory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hello_imgui/internal/backend_impls/runner_factory.cpp b/src/hello_imgui/internal/backend_impls/runner_factory.cpp index e49394a3..1ce35969 100644 --- a/src/hello_imgui/internal/backend_impls/runner_factory.cpp +++ b/src/hello_imgui/internal/backend_impls/runner_factory.cpp @@ -63,7 +63,11 @@ std::unique_ptr FactorRunner(RunnerParams& params) } else if (params.platformBackendType == PlatformBackendType::Null) { - return std::make_unique(params); + #ifdef HELLOIMGUI_USE_NULL + return std::make_unique(params); + #else + return nullptr; + #endif } else return nullptr; From aa78fabda1115e1f319624a160f380668c8b8ce1 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Wed, 10 Apr 2024 14:58:05 +0200 Subject: [PATCH 4/4] fix abstractRunner / use HELLOIMGUI_USE_NULL --- src/hello_imgui/internal/backend_impls/abstract_runner.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp index 0c545d3a..cef532b6 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp @@ -581,7 +581,11 @@ void AbstractRunner::InitRenderBackendCallbacks() } else if (params.rendererBackendType == RendererBackendType::Null) { - mRenderingBackendCallbacks = CreateBackendCallbacks_Null(); + #ifdef HELLOIMGUI_USE_NULL + mRenderingBackendCallbacks = CreateBackendCallbacks_Null(); + #else + IM_ASSERT(false && "Null backend is not available!"); + #endif } else {