afegida tecla per activar o desactivar el vsync

This commit is contained in:
2025-03-28 08:38:28 +01:00
parent 11d015daf8
commit 25cd6b00eb
13 changed files with 109 additions and 67 deletions

View File

@@ -313,7 +313,7 @@ bool Screen::initSDL()
}
else
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** SDL_VIDEO: INITIALIZING\n");
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "\n** SDL_VIDEO: INITIALIZING\n");
getDisplayInfo();
@@ -331,16 +331,6 @@ bool Screen::initSDL()
}
else
{
// Crea un renderizador para la ventana. El vsync se activa en función de las opciones
// Uint32 flags = 0;
if (options.video.v_sync)
{
// flags = SDL_RENDERER_PRESENTVSYNC;
}
// La aceleración se activa según el define
// flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
renderer_ = SDL_CreateRenderer(window_, nullptr);
if (!renderer_)
@@ -352,13 +342,14 @@ bool Screen::initSDL()
{
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
SDL_SetWindowFullscreen(window_, static_cast<Uint32>(options.video.fullscreen));
SDL_SetWindowFullscreen(window_, options.video.fullscreen);
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
}
}
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** SDL_VIDEO: INITIALIZATION COMPLETE\n");
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "** SDL_VIDEO: INITIALIZATION COMPLETE\n");
return success;
}
@@ -402,4 +393,18 @@ void Screen::getDisplayInfo()
SDL_free(displays);
}
}
// Activa / desactiva el escalado entero
void Screen::toggleIntegerScale()
{
options.video.integer_scale = !options.video.integer_scale;
SDL_SetRenderLogicalPresentation(Screen::get()->getRenderer(), param.game.width, param.game.height, options.video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
}
// Activa / desactiva el vsync
void Screen::toggleVSync()
{
options.video.v_sync = !options.video.v_sync;
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
}