Audio fix

This commit is contained in:
2026-03-14 19:11:59 +01:00
parent 52df67da09
commit b19f595daf
6 changed files with 67 additions and 37 deletions

View File

@@ -16,6 +16,7 @@ namespace Game::Window {
if (mWindow) {
SDL_DestroyWindow(mWindow);
mWindow = nullptr;
sWindowBackend = nullptr;
LOG("Window destroyed successfully");
}
SDL_Quit();
@@ -41,12 +42,14 @@ namespace Game::Window {
SDL_Quit();
return false;
}
sWindowBackend = mWindow;
LOG("Window created successfully");
if (!mRenderer.init(mWindow)) {
SDL_DestroyWindow(mWindow);
mWindow = nullptr;
sWindowBackend = nullptr;
SDL_Quit();
return false;
}
@@ -77,6 +80,17 @@ namespace Game::Window {
mRenderer.renderFrame();
SDL_Delay(1000 / mTargetFPS); // Delay to cap the frame rate to the target FPS
// Set the window title to show the current FPS for testing
mFrameCount++;
auto now = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(now - mLastFPSTime).count();
if (elapsed >= 1) {
int fps = static_cast<int>(mFrameCount / elapsed);
SDL_SetWindowTitle(mWindow, ("Game Window - FPS: " + std::to_string(fps)).c_str());
mFrameCount = 0;
mLastFPSTime = now;
}
}
}
}