From ea95054bd29ec6ebf4bbe4adce01c5aa7c3ba00d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 2 Jul 2020 16:37:11 +0200 Subject: [PATCH] Add the ability to render out the current recording time during a session recording --- .../openspace/interaction/sessionrecording.h | 9 +++++ src/engine/openspaceengine.cpp | 2 ++ src/interaction/sessionrecording.cpp | 36 ++++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/openspace/interaction/sessionrecording.h b/include/openspace/interaction/sessionrecording.h index b3856c5981..98ceb9b5ff 100644 --- a/include/openspace/interaction/sessionrecording.h +++ b/include/openspace/interaction/sessionrecording.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -65,6 +66,12 @@ public: */ void preSynchronization(); + /** + * If enabled, calling this function will render information about the session + * recording that is currently taking place to the screen. + */ + void render(); + /** * Current time based on playback mode */ @@ -209,6 +216,8 @@ public: std::vector playbackList() const; private: + properties::BoolProperty _renderPlaybackInformation; + enum class RecordedType { Camera = 0, Time, diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index c74410cb2d..41d13932bd 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1250,6 +1250,8 @@ void OpenSpaceEngine::drawOverlays() { if (isGuiWindow) { global::renderEngine.renderOverlays(_shutdown); global::luaConsole.render(); + global::sessionRecording.render(); + } for (const std::function& func : global::callback::draw2D) { diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index 849dc8d9e9..f79f8d1f2c 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include #include @@ -46,6 +48,13 @@ namespace { constexpr const char* _loggerCat = "SessionRecording"; + constexpr openspace::properties::Property::PropertyInfo RenderPlaybackInfo = { + "RenderInfo", + "Render Playback Information", + "If enabled, information about a currently played back session " + "recording is rendering to screen" + }; + constexpr const bool UsingTimeKeyframes = false; const std::string FileHeaderTitle = "OpenSpace_record/playback"; constexpr const size_t FileHeaderVersionLength = 5; @@ -101,7 +110,10 @@ namespace openspace::interaction { SessionRecording::SessionRecording() : properties::PropertyOwner({ "SessionRecording", "Session Recording" }) -{} + , _renderPlaybackInformation(RenderPlaybackInfo, false) +{ + addProperty(_renderPlaybackInformation); +} SessionRecording::~SessionRecording() {} // NOLINT @@ -615,6 +627,28 @@ void SessionRecording::preSynchronization() { _lastState = _state; } +void SessionRecording::render() { + ZoneScoped + + if (!(_renderPlaybackInformation && isPlayingBack())) { + return; + } + + + constexpr const char* FontName = "Mono"; + constexpr const float FontSizeFrameinfo = 32.f; + std::shared_ptr font = + global::fontManager.font(FontName, FontSizeFrameinfo); + + glm::vec2 res = global::renderEngine.fontResolution(); + glm::vec2 penPosition = glm::vec2( + res.x / 2 - 150.f, + res.y / 4 + ); + std::string text = std::to_string(currentTime()); + ghoul::fontrendering::RenderFont(*font, penPosition, text, glm::vec4(1.f)); +} + bool SessionRecording::isRecording() const { return (_state == SessionState::Recording); }