Don't use std::format

This commit is contained in:
MrLetsplay 2023-12-23 23:02:20 +01:00
parent 9bdfd80a13
commit 0ac8674e39
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 6 additions and 10 deletions

View File

@ -4,7 +4,6 @@
#include <algorithm>
#include <chrono>
#include <cstring>
#include <format>
#include <iostream>
#include <GL/glew.h>
@ -293,13 +292,7 @@ int start() {
int time = (int) (glfwGetTime() * 10);
if(time != prevTime) {
int fps = (int) floor(1.0f / kekData.lastTimings.frameTime);
std::string str = std::format("FPS: {} ({}) | Physics: {}, Lighting: {}, Render: {}, Idle: {}",
std::to_string(fps),
formatSeconds(kekData.lastTimings.frameTime),
formatSeconds(kekData.lastTimings.physicsTime),
formatSeconds(kekData.lastTimings.lightingTime),
formatSeconds(kekData.lastTimings.renderTime),
formatSeconds(kekData.lastTimings.idleTime));
std::string str = "FPS: " + std::to_string(fps) + " (" + formatSeconds(kekData.lastTimings.frameTime) + ")" + " | Physics: " + formatSeconds(kekData.lastTimings.physicsTime) + ", Lighting: " + formatSeconds(kekData.lastTimings.lightingTime) + ", Render: " + formatSeconds(kekData.lastTimings.renderTime) + ", Idle: " + formatSeconds(kekData.lastTimings.idleTime);
fpsText->setText(str);
}
prevTime = time;

View File

@ -1,7 +1,8 @@
#pragma once
#include <chrono>
#include <format>
#include <iomanip>
#include <sstream>
#include <string>
namespace kek {
@ -26,7 +27,9 @@ class Timer {
};
inline std::string formatSeconds(float seconds) {
return std::format("{:.2f} ms", seconds * 1000);
std::ostringstream s;
s << std::fixed << std::setprecision(2) << (seconds * 1000) << " ms";
return s.str();
}
}