mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 15:15:40 +00:00
SDL: Add a shoddy FPS counter
This commit is contained in:
parent
2a63dbce64
commit
e9bb3d79b8
|
@ -388,10 +388,12 @@ void SDLInterface::RenderDisplay()
|
|||
void SDLInterface::RenderImGui()
|
||||
{
|
||||
RenderMainMenuBar();
|
||||
RenderOSDMessages();
|
||||
|
||||
m_system->RenderUI();
|
||||
|
||||
RenderOSDMessages();
|
||||
RenderFPS();
|
||||
|
||||
ImGui::Render();
|
||||
}
|
||||
|
||||
|
@ -512,6 +514,27 @@ void SDLInterface::RenderOSDMessages()
|
|||
}
|
||||
}
|
||||
|
||||
void SDLInterface::RenderFPS()
|
||||
{
|
||||
// Position in the top-right corner of the screen.
|
||||
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - 2.0f, 2.0f), ImGuiCond_Always, ImVec2(1.0f, 0.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
ImGui::SetNextWindowSize(ImVec2(80.0f, 20.0f));
|
||||
|
||||
if (ImGui::Begin("FPS", nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav |
|
||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing |
|
||||
ImGuiWindowFlags_NoBackground))
|
||||
{
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.0f), "FPS: %.2f", m_fps);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void SDLInterface::DoLoadState(u32 index)
|
||||
{
|
||||
LoadState(GetSaveStateFilename(index));
|
||||
|
@ -538,6 +561,19 @@ void SDLInterface::Run()
|
|||
}
|
||||
|
||||
m_system->RunFrame();
|
||||
|
||||
// update fps counter
|
||||
{
|
||||
m_fps_counter++;
|
||||
const double time = m_fps_timer.GetTimeSeconds();
|
||||
if (time > 0.1)
|
||||
{
|
||||
m_fps = static_cast<float>(m_fps_counter / time);
|
||||
m_fps_counter = 0;
|
||||
m_fps_timer.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
void RenderDisplay();
|
||||
void RenderMainMenuBar();
|
||||
void RenderOSDMessages();
|
||||
void RenderFPS();
|
||||
|
||||
SDL_Window* m_window = nullptr;
|
||||
SDL_GLContext m_gl_context = nullptr;
|
||||
|
@ -76,4 +77,8 @@ private:
|
|||
std::mutex m_osd_messages_lock;
|
||||
|
||||
std::shared_ptr<DigitalController> m_controller;
|
||||
|
||||
float m_fps = 0.0f;
|
||||
u32 m_fps_counter = 0;
|
||||
Timer m_fps_timer;
|
||||
};
|
||||
|
|
|
@ -753,11 +753,7 @@ bool GPU::HandleCopyRectangleVRAMToVRAMCommand()
|
|||
return true;
|
||||
}
|
||||
|
||||
void GPU::UpdateDisplay()
|
||||
{
|
||||
m_render_state.texture_changed = true;
|
||||
m_system->IncrementFrameNumber();
|
||||
}
|
||||
void GPU::UpdateDisplay() {}
|
||||
|
||||
void GPU::ReadVRAM(u32 x, u32 y, u32 width, u32 height, void* buffer) {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue