afegit vsync toggle
This commit is contained in:
@@ -32,7 +32,7 @@ SDLManager::SDLManager()
|
||||
// Calcular mida màxima des del display
|
||||
calculateMaxWindowSize();
|
||||
|
||||
// Construir títol dinàmic igual que en pollo
|
||||
// Construir títol dinàmic
|
||||
std::string window_title = std::format("{} v{} ({})", Project::LONG_NAME, Project::VERSION, Project::COPYRIGHT);
|
||||
|
||||
// Crear finestra CENTRADA (SDL ho fa automàticament amb CENTERED)
|
||||
@@ -60,6 +60,9 @@ SDLManager::SDLManager()
|
||||
return;
|
||||
}
|
||||
|
||||
// Aplicar configuració de V-Sync
|
||||
SDL_SetRenderVSync(renderer_, Options::rendering.vsync);
|
||||
|
||||
// CRÍTIC: Configurar viewport scaling
|
||||
updateLogicalPresentation();
|
||||
|
||||
@@ -122,6 +125,9 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
return;
|
||||
}
|
||||
|
||||
// Aplicar configuració de V-Sync
|
||||
SDL_SetRenderVSync(renderer_, Options::rendering.vsync);
|
||||
|
||||
// Configurar viewport scaling
|
||||
updateLogicalPresentation();
|
||||
|
||||
@@ -343,3 +349,17 @@ void SDLManager::setWindowTitle(const std::string& title) {
|
||||
SDL_SetWindowTitle(finestra_, title.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// [NUEVO] Toggle V-Sync (F4)
|
||||
void SDLManager::toggleVSync() {
|
||||
// Toggle: 1 → 0 → 1
|
||||
Options::rendering.vsync = (Options::rendering.vsync == 1) ? 0 : 1;
|
||||
|
||||
// Aplicar a SDL
|
||||
if (renderer_) {
|
||||
SDL_SetRenderVSync(renderer_, Options::rendering.vsync);
|
||||
}
|
||||
|
||||
// Guardar configuració
|
||||
Options::saveToFile();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ class SDLManager {
|
||||
void increaseWindowSize(); // F2: +100px
|
||||
void decreaseWindowSize(); // F1: -100px
|
||||
void toggleFullscreen(); // F3
|
||||
void toggleVSync(); // F4
|
||||
bool
|
||||
handleWindowEvent(const SDL_Event& event); // Per a SDL_EVENT_WINDOW_RESIZED
|
||||
|
||||
|
||||
Reference in New Issue
Block a user