Add getMonoTimeMs to GE

This commit is contained in:
Benau 2022-05-27 09:41:34 +08:00
parent ac5351ae5e
commit 2b80513a8f
2 changed files with 14 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#define HEADER_GE_MAIN_HPP
#include <IVideoDriver.h>
#include <cstdint>
#include <string>
namespace GE
@ -19,6 +20,7 @@ GE::GEVulkanDriver* getVKDriver();
const std::string& getShaderFolder();
GEConfig* getGEConfig();
void deinit();
uint64_t getMonoTimeMs();
}
#endif

View File

@ -1,11 +1,15 @@
#include "ge_main.hpp"
#include "ge_vulkan_driver.hpp"
#include <chrono>
namespace GE
{
irr::video::IVideoDriver* g_driver = NULL;
GEConfig g_config = {};
std::string g_shader_folder = "";
std::chrono::steady_clock::time_point g_mono_start =
std::chrono::steady_clock::now();
void setVideoDriver(irr::video::IVideoDriver* driver)
{
@ -41,4 +45,12 @@ void deinit()
{
}
uint64_t getMonoTimeMs()
{
auto duration = std::chrono::steady_clock::now() - g_mono_start;
auto value =
std::chrono::duration_cast<std::chrono::milliseconds>(duration);
return value.count();
}
}