Audio fix
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user