canvis de upscale i downscale en consola
This commit is contained in:
@@ -536,12 +536,14 @@ auto loadData(const std::string& filepath) -> std::vector<uint8_t> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Screen::setLinearUpscale(bool linear) {
|
void Screen::setLinearUpscale(bool linear) {
|
||||||
|
Options::video.linear_upscale = linear;
|
||||||
if (shader_backend_ && shader_backend_->isHardwareAccelerated()) {
|
if (shader_backend_ && shader_backend_->isHardwareAccelerated()) {
|
||||||
shader_backend_->setLinearUpscale(linear);
|
shader_backend_->setLinearUpscale(linear);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::setDownscaleAlgo(int algo) {
|
void Screen::setDownscaleAlgo(int algo) {
|
||||||
|
Options::video.downscale_algo = algo;
|
||||||
if (shader_backend_ && shader_backend_->isHardwareAccelerated()) {
|
if (shader_backend_ && shader_backend_->isHardwareAccelerated()) {
|
||||||
shader_backend_->setDownscaleAlgo(algo);
|
shader_backend_->setDownscaleAlgo(algo);
|
||||||
}
|
}
|
||||||
@@ -580,9 +582,11 @@ void Screen::initShaders() {
|
|||||||
shader_backend_->init(window_, tex, "", "");
|
shader_backend_->init(window_, tex, "", "");
|
||||||
gpu_driver_ = shader_backend_->getDriverName();
|
gpu_driver_ = shader_backend_->getDriverName();
|
||||||
|
|
||||||
// Propagar flags de vsync e integer scale al backend GPU
|
// Propagar flags de vsync, integer scale, upscale y downscale al backend GPU
|
||||||
shader_backend_->setVSync(Options::video.vertical_sync);
|
shader_backend_->setVSync(Options::video.vertical_sync);
|
||||||
shader_backend_->setScaleMode(Options::video.integer_scale);
|
shader_backend_->setScaleMode(Options::video.integer_scale);
|
||||||
|
shader_backend_->setLinearUpscale(Options::video.linear_upscale);
|
||||||
|
shader_backend_->setDownscaleAlgo(Options::video.downscale_algo);
|
||||||
|
|
||||||
if (Options::video.postfx) {
|
if (Options::video.postfx) {
|
||||||
applyCurrentPostFXPreset();
|
applyCurrentPostFXPreset();
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ namespace Rendering {
|
|||||||
* Por defecto NEAREST (false). Solo tiene efecto con supersampling activo.
|
* Por defecto NEAREST (false). Solo tiene efecto con supersampling activo.
|
||||||
*/
|
*/
|
||||||
virtual void setLinearUpscale(bool /*linear*/) {}
|
virtual void setLinearUpscale(bool /*linear*/) {}
|
||||||
|
[[nodiscard]] virtual auto isLinearUpscale() const -> bool { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Selecciona el algoritmo de downscale tras el PostFX (SS activo).
|
* @brief Selecciona el algoritmo de downscale tras el PostFX (SS activo).
|
||||||
@@ -102,6 +103,7 @@ namespace Rendering {
|
|||||||
* 1 = Lanczos2 (ventana 2, ~25 muestras), 2 = Lanczos3 (ventana 3, ~49 muestras).
|
* 1 = Lanczos2 (ventana 2, ~25 muestras), 2 = Lanczos3 (ventana 3, ~49 muestras).
|
||||||
*/
|
*/
|
||||||
virtual void setDownscaleAlgo(int /*algo*/) {}
|
virtual void setDownscaleAlgo(int /*algo*/) {}
|
||||||
|
[[nodiscard]] virtual auto getDownscaleAlgo() const -> int { return 0; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Verifica si el backend está usando aceleración por hardware
|
* @brief Verifica si el backend está usando aceleración por hardware
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ namespace Defaults::Video {
|
|||||||
constexpr bool INTEGER_SCALE = true; // Escalado entero activado por defecto
|
constexpr bool INTEGER_SCALE = true; // Escalado entero activado por defecto
|
||||||
constexpr bool KEEP_ASPECT = true; // Mantener aspecto activado por defecto
|
constexpr bool KEEP_ASPECT = true; // Mantener aspecto activado por defecto
|
||||||
constexpr const char* PALETTE_NAME = "zx-spectrum"; // Paleta por defecto
|
constexpr const char* PALETTE_NAME = "zx-spectrum"; // Paleta por defecto
|
||||||
|
constexpr bool LINEAR_UPSCALE = false; // Upscale NEAREST por defecto
|
||||||
|
constexpr int DOWNSCALE_ALGO = 1; // Downscale Lanczos2 por defecto
|
||||||
} // namespace Defaults::Video
|
} // namespace Defaults::Video
|
||||||
|
|
||||||
namespace Defaults::Border {
|
namespace Defaults::Border {
|
||||||
|
|||||||
@@ -388,6 +388,22 @@ namespace Options {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vid.contains("linear_upscale")) {
|
||||||
|
try {
|
||||||
|
video.linear_upscale = vid["linear_upscale"].get_value<bool>();
|
||||||
|
} catch (...) {
|
||||||
|
video.linear_upscale = Defaults::Video::LINEAR_UPSCALE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vid.contains("downscale_algo")) {
|
||||||
|
try {
|
||||||
|
video.downscale_algo = vid["downscale_algo"].get_value<int>();
|
||||||
|
} catch (...) {
|
||||||
|
video.downscale_algo = Defaults::Video::DOWNSCALE_ALGO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadPaletteFromYaml(vid);
|
loadPaletteFromYaml(vid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,6 +660,8 @@ namespace Options {
|
|||||||
file << " vertical_sync: " << (video.vertical_sync ? "true" : "false") << "\n";
|
file << " vertical_sync: " << (video.vertical_sync ? "true" : "false") << "\n";
|
||||||
file << " integer_scale: " << (video.integer_scale ? "true" : "false") << "\n";
|
file << " integer_scale: " << (video.integer_scale ? "true" : "false") << "\n";
|
||||||
file << " keep_aspect: " << (video.keep_aspect ? "true" : "false") << "\n";
|
file << " keep_aspect: " << (video.keep_aspect ? "true" : "false") << "\n";
|
||||||
|
file << " linear_upscale: " << (video.linear_upscale ? "true" : "false") << "\n";
|
||||||
|
file << " downscale_algo: " << video.downscale_algo << " # 0=bilinear, 1=Lanczos2, 2=Lanczos3\n";
|
||||||
file << " palette: " << video.palette << "\n";
|
file << " palette: " << video.palette << "\n";
|
||||||
file << " border:\n";
|
file << " border:\n";
|
||||||
file << " enabled: " << (video.border.enabled ? "true" : "false") << "\n";
|
file << " enabled: " << (video.border.enabled ? "true" : "false") << "\n";
|
||||||
|
|||||||
@@ -84,9 +84,11 @@ namespace Options {
|
|||||||
bool supersampling{Defaults::Video::SUPERSAMPLING}; // Indica si el supersampling 3× está activo
|
bool supersampling{Defaults::Video::SUPERSAMPLING}; // Indica si el supersampling 3× está activo
|
||||||
bool integer_scale{Defaults::Video::INTEGER_SCALE}; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa
|
bool integer_scale{Defaults::Video::INTEGER_SCALE}; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa
|
||||||
bool keep_aspect{Defaults::Video::KEEP_ASPECT}; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
|
bool keep_aspect{Defaults::Video::KEEP_ASPECT}; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
|
||||||
Border border{}; // Borde de la pantalla
|
bool linear_upscale{Defaults::Video::LINEAR_UPSCALE}; // Upscale LINEAR (true) o NEAREST (false)
|
||||||
std::string palette{Defaults::Video::PALETTE_NAME}; // Paleta de colores a usar en el juego
|
int downscale_algo{Defaults::Video::DOWNSCALE_ALGO}; // 0=bilinear, 1=Lanczos2, 2=Lanczos3
|
||||||
std::string info; // Información sobre el modo de vídeo
|
Border border{}; // Borde de la pantalla
|
||||||
|
std::string palette{Defaults::Video::PALETTE_NAME}; // Paleta de colores a usar en el juego
|
||||||
|
std::string info; // Información sobre el modo de vídeo
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para las opciones de musica
|
// Estructura para las opciones de musica
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ static void printHelp() {
|
|||||||
SDL_Log(" FULLSCREEN [ON|OFF] Fullscreen mode (F3)");
|
SDL_Log(" FULLSCREEN [ON|OFF] Fullscreen mode (F3)");
|
||||||
SDL_Log(" ZOOM [UP|DOWN] Window zoom (F1/F2)");
|
SDL_Log(" ZOOM [UP|DOWN] Window zoom (F1/F2)");
|
||||||
SDL_Log(" INTSCALE [ON|OFF] Integer scaling (F7)");
|
SDL_Log(" INTSCALE [ON|OFF] Integer scaling (F7)");
|
||||||
|
SDL_Log(" UPSCALE [NEAREST|LINEAR] SS upscale filter (toggle if no arg)");
|
||||||
|
SDL_Log(" DOWNSCALE [BILINEAR|LANCZOS2|LANCZOS3] SS downscale algorithm");
|
||||||
SDL_Log(" VSYNC [ON|OFF] Vertical sync");
|
SDL_Log(" VSYNC [ON|OFF] Vertical sync");
|
||||||
SDL_Log(" PALETTE [NEXT|PREV] Color palette (F5/F6)");
|
SDL_Log(" PALETTE [NEXT|PREV] Color palette (F5/F6)");
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -173,6 +175,41 @@ static const std::vector<ConsoleCommand> COMMANDS = {
|
|||||||
return std::string("IntScale ") + (Options::video.integer_scale ? "ON" : "OFF");
|
return std::string("IntScale ") + (Options::video.integer_scale ? "ON" : "OFF");
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
// UPSCALE [NEAREST|LINEAR] — Filtro de upscale en supersampling
|
||||||
|
{.keyword = "UPSCALE", .execute = [](const std::vector<std::string>& args) -> std::string {
|
||||||
|
if (args.empty()) {
|
||||||
|
Screen::get()->setLinearUpscale(!Options::video.linear_upscale);
|
||||||
|
return std::string("Upscale: ") + (Options::video.linear_upscale ? "Linear" : "Nearest");
|
||||||
|
}
|
||||||
|
if (args[0] == "NEAREST") {
|
||||||
|
if (!Options::video.linear_upscale) { return "Upscale already Nearest"; }
|
||||||
|
Screen::get()->setLinearUpscale(false); return "Upscale: Nearest";
|
||||||
|
}
|
||||||
|
if (args[0] == "LINEAR") {
|
||||||
|
if (Options::video.linear_upscale) { return "Upscale already Linear"; }
|
||||||
|
Screen::get()->setLinearUpscale(true); return "Upscale: Linear";
|
||||||
|
}
|
||||||
|
return "Usage: UPSCALE [NEAREST|LINEAR]";
|
||||||
|
}},
|
||||||
|
|
||||||
|
// DOWNSCALE [BILINEAR|LANCZOS2|LANCZOS3] — Algoritmo de downscale en supersampling
|
||||||
|
{.keyword = "DOWNSCALE", .execute = [](const std::vector<std::string>& args) -> std::string {
|
||||||
|
static const std::array<std::string_view, 3> NAMES = {"Bilinear", "Lanczos2", "Lanczos3"};
|
||||||
|
if (args.empty()) {
|
||||||
|
return std::string("Downscale: ") + std::string(NAMES[static_cast<size_t>(Options::video.downscale_algo)]);
|
||||||
|
}
|
||||||
|
int algo = -1;
|
||||||
|
if (args[0] == "BILINEAR") { algo = 0; }
|
||||||
|
if (args[0] == "LANCZOS2") { algo = 1; }
|
||||||
|
if (args[0] == "LANCZOS3") { algo = 2; }
|
||||||
|
if (algo == -1) { return "Usage: DOWNSCALE [BILINEAR|LANCZOS2|LANCZOS3]"; }
|
||||||
|
if (Options::video.downscale_algo == algo) {
|
||||||
|
return std::string("Downscale already ") + std::string(NAMES[static_cast<size_t>(algo)]);
|
||||||
|
}
|
||||||
|
Screen::get()->setDownscaleAlgo(algo);
|
||||||
|
return std::string("Downscale: ") + std::string(NAMES[static_cast<size_t>(algo)]);
|
||||||
|
}},
|
||||||
|
|
||||||
// VSYNC [ON|OFF] — Sincronización vertical
|
// VSYNC [ON|OFF] — Sincronización vertical
|
||||||
{.keyword = "VSYNC", .execute = BOOL_TOGGLE_CMD("VSync",
|
{.keyword = "VSYNC", .execute = BOOL_TOGGLE_CMD("VSync",
|
||||||
Options::video.vertical_sync,
|
Options::video.vertical_sync,
|
||||||
|
|||||||
Reference in New Issue
Block a user