From d1892e151f4fdeeb93f23beaddd69df6b53edeca Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 24 Nov 2021 22:46:37 +0000 Subject: [PATCH] Expose puglGetTime as Application::getTime --- dgl/Application.hpp | 9 +++++++++ dgl/src/Application.cpp | 5 +++++ dgl/src/ApplicationPrivateData.cpp | 7 +++++++ dgl/src/ApplicationPrivateData.hpp | 3 +++ 4 files changed, 24 insertions(+) diff --git a/dgl/Application.hpp b/dgl/Application.hpp index 87937cc7..1024e226 100644 --- a/dgl/Application.hpp +++ b/dgl/Application.hpp @@ -80,6 +80,15 @@ public: */ bool isStandalone() const noexcept; + /** + Return the time in seconds. + + This is a monotonically increasing clock with high resolution.@n + The returned time is only useful to compare against other times returned by this function, + its absolute value has no meaning. + */ + double getTime() const; + /** Add a callback function to be triggered on every idle cycle. You can add more than one, and remove them at anytime with removeIdleCallback(). diff --git a/dgl/src/Application.cpp b/dgl/src/Application.cpp index 12191f7a..5d6529a9 100644 --- a/dgl/src/Application.cpp +++ b/dgl/src/Application.cpp @@ -56,6 +56,11 @@ bool Application::isStandalone() const noexcept return pData->isStandalone; } +double Application::getTime() const +{ + return pData->getTime(); +} + void Application::addIdleCallback(IdleCallback* const callback) { DISTRHO_SAFE_ASSERT_RETURN(callback != nullptr,) diff --git a/dgl/src/ApplicationPrivateData.cpp b/dgl/src/ApplicationPrivateData.cpp index f573c2f7..f54535fc 100644 --- a/dgl/src/ApplicationPrivateData.cpp +++ b/dgl/src/ApplicationPrivateData.cpp @@ -152,6 +152,13 @@ void Application::PrivateData::quit() #endif } +double Application::PrivateData::getTime() const +{ + DISTRHO_SAFE_ASSERT_RETURN(world != nullptr, 0.0); + + return puglGetTime(world); +} + void Application::PrivateData::setClassName(const char* const name) { DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,); diff --git a/dgl/src/ApplicationPrivateData.hpp b/dgl/src/ApplicationPrivateData.hpp index 0d2993c4..c3030b06 100644 --- a/dgl/src/ApplicationPrivateData.hpp +++ b/dgl/src/ApplicationPrivateData.hpp @@ -91,6 +91,9 @@ struct Application::PrivateData { For standalone mode only. */ void quit(); + /** Get time via pugl */ + double getTime() const; + /** Set pugl world class name. */ void setClassName(const char* name);