22 lines
647 B
C++
22 lines
647 B
C++
|
|
#include "iwa/addons/imgui/fps_widget.hpp"
|
|
|
|
#include <fmt/format.h>
|
|
#include <imgui.h>
|
|
|
|
namespace iwa
|
|
{
|
|
void ImGuiFpsWidget::draw()
|
|
{
|
|
mFpsCalculator.tickFrame();
|
|
|
|
const std::string fpsText = fmt::format("{}", static_cast<unsigned>(mFpsCalculator.getFps()));
|
|
const ImVec2 textSize = ImGui::CalcTextSize(fpsText.c_str());
|
|
ImGui::SetNextWindowPos(ImVec2(0, 0));
|
|
ImGui::SetNextWindowSize(ImVec2(textSize.x + 2 * ImGui::GetStyle().WindowPadding.x, 0));
|
|
ImGui::Begin("#fps", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs);
|
|
ImGui::TextUnformatted(fpsText.c_str());
|
|
ImGui::End();
|
|
}
|
|
} // namespace iwa
|