mes comandos per a Console

This commit is contained in:
2026-03-28 14:14:33 +01:00
parent 854a5f04b2
commit 71c7b8e553
6 changed files with 47 additions and 3 deletions

View File

@@ -529,6 +529,11 @@ void Screen::setDownscaleAlgo(int algo) {
}
}
auto Screen::getSsTextureSize() const -> std::pair<int, int> {
if (!shader_backend_) { return {0, 0}; }
return shader_backend_->getSsTextureSize();
}
// Activa/desactiva el supersampling global (Ctrl+F4)
void Screen::toggleSupersampling() {
Options::video.supersampling = !Options::video.supersampling;

View File

@@ -6,6 +6,7 @@
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr, __shared_ptr_access
#include <string> // Para string
#include <utility> // Para std::pair
#include <vector> // Para vector
#include "utils/utils.hpp" // Para Color
@@ -77,6 +78,7 @@ class Screen {
[[nodiscard]] auto getGPUDriver() const -> const std::string& { return gpu_driver_; }
[[nodiscard]] auto getLastFPS() const -> int { return fps_.last_value; }
[[nodiscard]] auto getZoomFactor() const -> float { return zoom_factor_; }
[[nodiscard]] auto getSsTextureSize() const -> std::pair<int, int>;
private:
// Estructuras

View File

@@ -924,6 +924,11 @@ namespace Rendering {
downscale_algo_ = std::max(0, std::min(algo, 2));
}
auto SDL3GPUShader::getSsTextureSize() const -> std::pair<int, int> {
if (ss_factor_ <= 1) { return {0, 0}; }
return {game_width_ * ss_factor_, game_height_ * ss_factor_};
}
// ---------------------------------------------------------------------------
// reinitTexturesAndBuffer — recrea scene_texture_, scaled_texture_ y
// upload_buffer_ con el factor oversample_ actual. No toca pipelines ni samplers.

View File

@@ -82,6 +82,9 @@ namespace Rendering {
// Selecciona algoritmo de downscale: 0=bilinear legacy, 1=Lanczos2, 2=Lanczos3
void setDownscaleAlgo(int algo) override;
// Devuelve las dimensiones de la textura de supersampling (0,0 si SS desactivado)
[[nodiscard]] auto getSsTextureSize() const -> std::pair<int, int> override;
private:
static auto createShaderMSL(SDL_GPUDevice* device,
const char* msl_source,

View File

@@ -3,6 +3,7 @@
#include <SDL3/SDL.h>
#include <string>
#include <utility>
namespace Rendering {
@@ -105,6 +106,12 @@ namespace Rendering {
virtual void setDownscaleAlgo(int /*algo*/) {}
[[nodiscard]] virtual auto getDownscaleAlgo() const -> int { return 0; }
/**
* @brief Devuelve las dimensiones de la textura de supersampling.
* @return Par (ancho, alto) en píxeles; (0, 0) si SS está desactivado.
*/
[[nodiscard]] virtual auto getSsTextureSize() const -> std::pair<int, int> { return {0, 0}; }
/**
* @brief Verifica si el backend está usando aceleración por hardware
* @return true si usa aceleración (OpenGL/Metal/Vulkan)

View File

@@ -74,7 +74,7 @@ static auto parseTokens(const std::string& input) -> std::vector<std::string> {
// Texto de ayuda común para HELP y ?
static void printHelp() {
SDL_Log("=== JDD CONSOLE COMMANDS ===");
SDL_Log(" SS [ON|OFF] Supersampling (Ctrl+F4)");
SDL_Log(" SS [ON|OFF|SIZE] Supersampling (Ctrl+F4)");
SDL_Log(" POSTFX [ON|OFF|NEXT] Post-FX / next preset (F4/Shift+F4)");
SDL_Log(" BORDER [ON|OFF] Decorative border (B)");
SDL_Log(" FULLSCREEN [ON|OFF] Fullscreen mode (F3)");
@@ -107,8 +107,30 @@ static void printHelp() {
// Tabla de comandos disponibles
static const std::vector<ConsoleCommand> COMMANDS = {
// SS [ON|OFF] — Supersampling (Ctrl+F4)
{.keyword = "SS", .execute = BOOL_TOGGLE_CMD("Supersampling", Options::video.supersampling, Screen::get()->toggleSupersampling())},
// SS [ON|OFF|SIZE] — Supersampling (Ctrl+F4)
{.keyword = "SS", .execute = [](const std::vector<std::string>& args) -> std::string {
if (!args.empty() && args[0] == "SIZE") {
if (!Options::video.supersampling) { return "Supersampling OFF"; }
const auto [w, h] = Screen::get()->getSsTextureSize();
if (w == 0) { return "SS texture: not active"; }
return "SS texture: " + std::to_string(w) + "x" + std::to_string(h);
}
if (args.empty()) {
Screen::get()->toggleSupersampling();
return std::string("Supersampling ") + (Options::video.supersampling ? "ON" : "OFF");
}
if (args[0] == "ON") {
if (Options::video.supersampling) { return "Supersampling already ON"; }
Screen::get()->toggleSupersampling();
return "Supersampling ON";
}
if (args[0] == "OFF") {
if (!Options::video.supersampling) { return "Supersampling already OFF"; }
Screen::get()->toggleSupersampling();
return "Supersampling OFF";
}
return "Usage: SS [ON|OFF|SIZE]";
}},
// POSTFX [ON|OFF|NEXT] — PostFX y presets (F4 / Shift+F4)
{.keyword = "POSTFX", .execute = [](const std::vector<std::string>& args) -> std::string {