From 724ad5b55346bb2d16d0a1a051b028bd216689aa Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sat, 3 Jul 2021 19:00:12 +0200 Subject: [PATCH] Reduce fontsize of shutdown warning and center it instead with a dimming of the rendering (#1675) * Reduce fontsize of shutdown warning and center it instead with a dimming of the rendering --- openspace.cfg | 2 +- src/engine/openspaceengine.cpp | 1 - src/rendering/renderengine.cpp | 59 ++++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/openspace.cfg b/openspace.cfg index 3e4332c32a..3a5e56d9e0 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -190,7 +190,7 @@ Fonts = { } FontSize = { FrameInfo = 32.0, - Shutdown = 30.0, + Shutdown = 14.0, Log = 8.0, CameraInfo = 12.0, VersionInfo = 12.0 diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index be72b1076b..b75e828183 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1270,7 +1270,6 @@ void OpenSpaceEngine::drawOverlays() { for (const std::function& func : *global::callback::draw2D) { ZoneScopedN("[Module] draw2D") - func(); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 212321d0d9..21d63a2c28 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -65,7 +66,7 @@ #ifdef GHOUL_USE_DEVIL #include -#endif //GHOUL_USE_DEVIL +#endif // GHOUL_USE_DEVIL #ifdef GHOUL_USE_FREEIMAGE #include #endif // GHOUL_USE_FREEIMAGE @@ -74,7 +75,7 @@ #include #include #include -#endif //GHOUL_USE_SOIL +#endif // GHOUL_USE_SOIL #ifdef GHOUL_USE_STB_IMAGE #include @@ -863,14 +864,9 @@ void RenderEngine::renderOverlays(const ShutdownInformation& shutdownInfo) { renderScreenLog(); renderVersionInformation(); renderDashboard(); + renderCameraInformation(); - if (!shutdownInfo.inShutdown) { - // We render the camera information in the same location as the shutdown info - // and we won't need this if we are shutting down - renderCameraInformation(); - } - else { - // If we are in shutdown mode, we can display the remaining time + if (shutdownInfo.inShutdown) { renderShutdownInformation(shutdownInfo.timer, shutdownInfo.waitTime); } } @@ -890,12 +886,13 @@ void RenderEngine::renderEndscreen() { glm::vec2(global::windowDelegate->currentSubwindowSize()) / dpiScaling; glViewport(0, 0, res.x, res.y); - const glm::vec2 size = _fontShutdown->boundingBox("Shutting down"); + constexpr const std::string_view Text = "Shutting down"; + const glm::vec2 size = _fontShutdown->boundingBox(Text); glm::vec2 penPosition = glm::vec2( fontResolution().x / 2 - size.x / 2, fontResolution().y / 2 - size.y / 2 ); - RenderFont(*_fontShutdown, penPosition, "Shutting down"); + RenderFont(*_fontShutdown, penPosition, Text); } void RenderEngine::renderShutdownInformation(float timer, float fullTime) { @@ -903,30 +900,42 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) { timer = std::max(timer, 0.f); - const glm::vec2 size = _fontShutdown->boundingBox( - fmt::format("Shutdown in: {:.2f}s/{:.2f}s", timer, fullTime) + // Render progressive overlay + glEnable(GL_BLEND); + + // t = 1.f -> start of shutdown counter t = 0.f -> timer has reached shutdown + float t = 1.f - (timer / fullTime); + + rendering::helper::renderBox( + glm::vec2(0.f), + glm::vec2(1.f), + glm::vec4(0.f, 0.f, 0.f, ghoul::circularEaseOut(t)) + ); + + // No need to print the text if we are just about to finish since otherwise we'll be + // overplotting the actual "shutdown in progress" text + if (timer == 0.f) { + return; + } + + constexpr const std::string_view FirstLine = "Shutdown in: {:.2f}s/{:.2f}s"; + const glm::vec2 size1 = _fontShutdown->boundingBox( + fmt::format(FirstLine, timer, fullTime) ); glm::vec2 penPosition = glm::vec2( - fontResolution().x - size.x - 10, - fontResolution().y - size.y + fontResolution().x / 2 - size1.x / 2, + fontResolution().y / 2 - size1.y / 2 ); RenderFont( *_fontShutdown, penPosition, - fmt::format("Shutdown in: {:.2f}s/{:.2f}s", timer, fullTime), - ghoul::fontrendering::CrDirection::Down - ); - - RenderFont( - *_fontShutdown, - penPosition, - // Important: length of this string is the same as the shutdown time text - // to make them align - "Press ESC again to abort", + fmt::format(FirstLine, timer, fullTime), ghoul::fontrendering::CrDirection::Down ); + // Important: Length of this string is the same as the first line to make them align + RenderFont(*_fontShutdown, penPosition, "Press ESC again to abort"); } void RenderEngine::renderDashboard() {