diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 5eca90961..7f4af6679 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -117,6 +117,9 @@ namespace Ndk void SetupFPSCounter(WindowInfo& info); void SetupOverlay(WindowInfo& info); + template void SetupWindow(WindowInfo& info, T* renderTarget, std::true_type /*isRenderTarget*/); + template void SetupWindow(WindowInfo& /*info*/, T* /*renderTarget*/, std::false_type /*isNotRenderTarget*/); + std::vector m_windows; #endif std::list m_worlds; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index d7e0325d9..a36ee3a13 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -85,21 +85,7 @@ namespace Ndk T& window = static_cast(*info.window.get()); //< Warning: ugly - if (std::is_base_of()) - { - info.renderTarget = &window; - - if (m_overlayFlags) - { - SetupOverlay(info); - - if (m_overlayFlags & OverlayFlags_Console) - SetupConsole(info); - - if (m_overlayFlags & OverlayFlags_FPSCounter) - SetupFPSCounter(info); - } - } + SetupWindow(info, &window, std::is_base_of()); return window; } @@ -138,7 +124,10 @@ namespace Ndk } for (WindowInfo& info : m_windows) - SetupConsole(info); + { + if (info.renderTarget) + SetupConsole(info); + } m_overlayFlags |= OverlayFlags_Console; @@ -178,7 +167,10 @@ namespace Ndk } for (WindowInfo& info : m_windows) - SetupFPSCounter(info); + { + if (info.renderTarget) + SetupFPSCounter(info); + } m_overlayFlags |= OverlayFlags_FPSCounter; @@ -310,6 +302,28 @@ namespace Ndk return s_application; } + template + inline void Application::SetupWindow(WindowInfo& info, T* renderTarget, std::true_type) + { + info.renderTarget = renderTarget; + + if (m_overlayFlags) + { + SetupOverlay(info); + + if (m_overlayFlags & OverlayFlags_Console) + SetupConsole(info); + + if (m_overlayFlags & OverlayFlags_FPSCounter) + SetupFPSCounter(info); + } + } + + template + inline void Application::SetupWindow(WindowInfo&, T*, std::false_type) + { + } + #ifndef NDK_SERVER inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : window(std::move(window)),