Add the ability to render out the current recording time during a session recording

This commit is contained in:
Alexander Bock
2020-07-02 16:37:11 +02:00
parent cae025f530
commit ea95054bd2
3 changed files with 46 additions and 1 deletions

View File

@@ -27,6 +27,7 @@
#include <openspace/interaction/externinteraction.h>
#include <openspace/interaction/keyframenavigator.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/scripting/lualibrary.h>
#include <vector>
@@ -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<std::string> playbackList() const;
private:
properties::BoolProperty _renderPlaybackInformation;
enum class RecordedType {
Camera = 0,
Time,

View File

@@ -1250,6 +1250,8 @@ void OpenSpaceEngine::drawOverlays() {
if (isGuiWindow) {
global::renderEngine.renderOverlays(_shutdown);
global::luaConsole.render();
global::sessionRecording.render();
}
for (const std::function<void()>& func : global::callback::draw2D) {

View File

@@ -39,6 +39,8 @@
#include <openspace/util/timemanager.h>
#include <ghoul/filesystem/file.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/profiling.h>
#include <iomanip>
@@ -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<ghoul::fontrendering::Font> 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);
}