afegits tots els valors d'escala que dona sdl3
This commit is contained in:
@@ -814,7 +814,7 @@ namespace Rendering {
|
||||
|
||||
// ---- Upscale pass: scene_texture_ → scaled_texture_ ----
|
||||
// Si 4:3 actiu, l'estirament s'aplica ací directament (320x200 → W*factor × H*factor*1.2)
|
||||
// El filtre per al 4:3 és configurable (stretch_filter_linear_).
|
||||
// El filtre s'aplica sempre (texture_filter_linear_), independent de 4:3.
|
||||
// L'effective_scene/height reflecteix la textura real que veuen els shaders.
|
||||
// Sense SS ni stretch: scene_texture_ a game_height_.
|
||||
// Amb SS o stretch: scaled_texture_ a l'alçada escalada (amb o sense 4:3).
|
||||
@@ -827,9 +827,8 @@ namespace Rendering {
|
||||
upscale_target.load_op = SDL_GPU_LOADOP_DONT_CARE;
|
||||
upscale_target.store_op = SDL_GPU_STOREOP_STORE;
|
||||
|
||||
// Triar filtre: si 4:3 actiu, usar el filtre configurable per a l'estirament.
|
||||
// Si no, usar el filtre d'upscale normal (linear_upscale_).
|
||||
bool use_linear = stretch_4_3_ ? stretch_filter_linear_ : linear_upscale_;
|
||||
// Filtre global: s'aplica sempre (ja no depèn de 4:3).
|
||||
bool use_linear = texture_filter_linear_;
|
||||
|
||||
SDL_GPURenderPass* upass = SDL_BeginGPURenderPass(cmd, &upscale_target, 1, nullptr);
|
||||
if (upass != nullptr) {
|
||||
@@ -872,16 +871,38 @@ namespace Rendering {
|
||||
float vy = 0.0F;
|
||||
float vw = 0.0F;
|
||||
float vh = 0.0F;
|
||||
if (integer_scale_) {
|
||||
const int SCALE = std::max(1, std::min(static_cast<int>(sw) / static_cast<int>(logical_w), static_cast<int>(sh) / static_cast<int>(logical_h)));
|
||||
vw = logical_w * static_cast<float>(SCALE);
|
||||
vh = logical_h * static_cast<float>(SCALE);
|
||||
} else {
|
||||
const float SCALE = std::min(
|
||||
static_cast<float>(sw) / logical_w,
|
||||
static_cast<float>(sh) / logical_h);
|
||||
vw = logical_w * SCALE;
|
||||
vh = logical_h * SCALE;
|
||||
switch (scaling_mode_) {
|
||||
case Options::ScalingMode::DISABLED:
|
||||
// 1:1, sense escala (pot ser diminut en finestres grans)
|
||||
vw = logical_w;
|
||||
vh = logical_h;
|
||||
break;
|
||||
case Options::ScalingMode::STRETCH:
|
||||
// Omple tota la finestra, escala no uniforme
|
||||
vw = static_cast<float>(sw);
|
||||
vh = static_cast<float>(sh);
|
||||
break;
|
||||
case Options::ScalingMode::LETTERBOX: {
|
||||
const float SCALE = std::min(static_cast<float>(sw) / logical_w,
|
||||
static_cast<float>(sh) / logical_h);
|
||||
vw = logical_w * SCALE;
|
||||
vh = logical_h * SCALE;
|
||||
break;
|
||||
}
|
||||
case Options::ScalingMode::OVERSCAN: {
|
||||
const float SCALE = std::max(static_cast<float>(sw) / logical_w,
|
||||
static_cast<float>(sh) / logical_h);
|
||||
vw = logical_w * SCALE;
|
||||
vh = logical_h * SCALE;
|
||||
break;
|
||||
}
|
||||
case Options::ScalingMode::INTEGER: {
|
||||
const int SCALE = std::max(1, std::min(static_cast<int>(sw) / static_cast<int>(logical_w),
|
||||
static_cast<int>(sh) / static_cast<int>(logical_h)));
|
||||
vw = logical_w * static_cast<float>(SCALE);
|
||||
vh = logical_h * static_cast<float>(SCALE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
vx = std::floor((static_cast<float>(sw) - vw) * 0.5F);
|
||||
vy = std::floor((static_cast<float>(sh) - vh) * 0.5F);
|
||||
@@ -1193,8 +1214,8 @@ namespace Rendering {
|
||||
}
|
||||
}
|
||||
|
||||
void SDL3GPUShader::setScaleMode(bool integer_scale) {
|
||||
integer_scale_ = integer_scale;
|
||||
void SDL3GPUShader::setScalingMode(Options::ScalingMode mode) {
|
||||
scaling_mode_ = mode;
|
||||
}
|
||||
|
||||
void SDL3GPUShader::setStretch4_3(bool enabled) {
|
||||
@@ -1221,10 +1242,6 @@ namespace Rendering {
|
||||
}
|
||||
}
|
||||
|
||||
void SDL3GPUShader::setLinearUpscale(bool linear) {
|
||||
linear_upscale_ = linear;
|
||||
}
|
||||
|
||||
void SDL3GPUShader::setDownscaleAlgo(int algo) {
|
||||
downscale_algo_ = std::max(0, std::min(algo, 2));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user