diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 2e2924e121..7596db9732 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -76,6 +76,8 @@ public: float globalOpacity(); void setGlobalOpacity(float opacity); + + void setSGCTRenderStatistics(bool visible); /** * Returns the Lua library that contains all Lua functions available to affect the @@ -114,6 +116,7 @@ private: float _fadeDuration; float _currentFadeTime; int _fadeDirection; + bool _sgctRenderStatisticsVisible; bool _visualizeABuffer; ABufferVisualizer* _visualizer; diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index d8fcb31407..2772ec5b99 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -149,6 +149,23 @@ namespace openspace { return 0; } + /** + * \ingroup LuaScripts + * showSGCTRenderStatistics(bool): + * Set the rendering of the SGCTRenderStatistics + */ + int showSGCTRenderStatistics(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + + const int type = lua_type(L, -1); + if (type != LUA_TBOOLEAN) + return luaL_error(L, "Expected argument of type 'bool'"); + bool b = lua_toboolean(L, -1) != 0; + OsEng.renderEngine()->setSGCTRenderStatistics(b); + } + /** * \ingroup LuaScripts * visualizeABuffer(bool): @@ -214,7 +231,7 @@ namespace openspace { , _fadeDuration(2.f) , _currentFadeTime(0.f) , _fadeDirection(0) - + , _sgctRenderStatisticsVisible(false) { } @@ -367,6 +384,7 @@ namespace openspace { void RenderEngine::postSynchronizationPreDraw() { + sgct::Engine::instance()->setStatsGraphVisibility(_sgctRenderStatisticsVisible); //temporary fade funtionality if (_fadeDirection != 0){ if (_currentFadeTime > _fadeDuration){ @@ -736,6 +754,12 @@ namespace openspace { "bool", "Toggles the showing of render information on-screen text" }, + { + "showSGCTRenderStatistics", + &luascriptfunctions::showSGCTRenderStatistics, + "bool", + "Toggles the visibility of the SGCT rendering information" + }, { "setPerformanceMeasurement", &luascriptfunctions::setPerformanceMeasurement, @@ -897,4 +921,8 @@ void RenderEngine::changeViewPoint(std::string origin) { } +void RenderEngine::setSGCTRenderStatistics(bool visible) { + _sgctRenderStatisticsVisible = visible; +} + }// namespace openspace