mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Added FrameTime. (#3521)
This commit is contained in:
committed by
GitHub
parent
9d63c39a44
commit
3ddf1ed032
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user