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

@@ -241,7 +241,7 @@ public:
&& bgfx::isTextureValid(0, false, 1, bgfx::TextureFormat::R16F, BGFX_TEXTURE_RT)
;
m_timeOffset = bx::getHPCounter();
m_frameTime.reset();
}
int shutdown() override
@@ -275,6 +275,9 @@ public:
{
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
{
m_frameTime.frame();
const float time = bx::toSeconds<float>(m_frameTime.getDurationTime() );
imguiBeginFrame(m_mouseState.m_mx
, m_mouseState.m_my
, (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
@@ -345,10 +348,6 @@ public:
bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
bgfx::setViewRect(1, 0, 0, uint16_t(m_width), uint16_t(m_height) );
int64_t now = bx::getHPCounter();
const double freq = double(bx::getHPFrequency() );
float time = (float)( (now-m_timeOffset)/freq);
// Reference(s):
// - Weighted, Blended Order-Independent Transparency
// https://web.archive.org/save/http://jcgt.org/published/0002/02/09/
@@ -532,8 +531,6 @@ public:
entry::MouseState m_mouseState;
int64_t m_timeOffset;
bgfx::VertexBufferHandle m_vbh;
bgfx::IndexBufferHandle m_ibh;
@@ -549,6 +546,8 @@ public:
bgfx::TextureHandle m_fbtextures[2];
bgfx::FrameBufferHandle m_fbh;
FrameTime m_frameTime;
};
} // namespace