Added FrameTime. (#3521)

This commit is contained in:
Branimir Karadžić
2025-12-23 20:03:52 -08:00
committed by GitHub
parent 9d63c39a44
commit 3ddf1ed032
47 changed files with 608 additions and 590 deletions

View File

@@ -296,7 +296,7 @@ public:
cameraSetPosition({ 0.0f, 2.0f, -12.0f });
cameraSetVerticalAngle(0.0f);
m_timeOffset = bx::getHPCounter();
m_frameTime.reset();
}
virtual int shutdown() override
@@ -324,18 +324,14 @@ public:
{
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
{
m_frameTime.frame();
const float deltaTime = bx::toSeconds<float>(m_frameTime.getDeltaTime() );
// Set view 0 default viewport.
bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
bgfx::touch(0);
int64_t now = bx::getHPCounter() - m_timeOffset;
static int64_t last = now;
const int64_t frameTime = now - last;
last = now;
const double freq = double(bx::getHPFrequency() );
const float deltaTime = float(frameTime/freq);
cameraUpdate(deltaTime, m_mouseState, ImGui::MouseOverArea() );
float view[16];
@@ -443,14 +439,14 @@ public:
entry::MouseState m_mouseState;
int64_t m_timeOffset;
uint32_t m_width;
uint32_t m_height;
uint32_t m_debug;
uint32_t m_reset;
Emitter m_emitter[4];
FrameTime m_frameTime;
};
} // namespace