afegits tots els valors d'escala que dona sdl3
This commit is contained in:
@@ -98,11 +98,10 @@ void Screen::initShaders() {
|
||||
std::cout << "GPU driver: " << gpu_driver_ << '\n';
|
||||
|
||||
// Aplica opcions de vídeo
|
||||
shader_backend_->setScaleMode(Options::video.integer_scale);
|
||||
shader_backend_->setScalingMode(Options::video.scaling_mode);
|
||||
shader_backend_->setVSync(Options::video.vsync);
|
||||
shader_backend_->setStretchFilter(Options::video.stretch_filter_linear);
|
||||
shader_backend_->setTextureFilter(Options::video.texture_filter);
|
||||
shader_backend_->setStretch4_3(Options::video.aspect_ratio_4_3);
|
||||
shader_backend_->setLinearUpscale(Options::video.linear_upscale);
|
||||
shader_backend_->setDownscaleAlgo(Options::video.downscale_algo);
|
||||
|
||||
if (Options::video.supersampling) {
|
||||
@@ -211,10 +210,14 @@ void Screen::toggleAspectRatio() {
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::toggleIntegerScale() {
|
||||
Options::video.integer_scale = !Options::video.integer_scale;
|
||||
void Screen::cycleScalingMode(int dir) {
|
||||
constexpr int N = 5; // DISABLED, STRETCH, LETTERBOX, OVERSCAN, INTEGER
|
||||
int cur = static_cast<int>(Options::video.scaling_mode);
|
||||
int step = (dir >= 0) ? 1 : -1;
|
||||
cur = ((cur + step) % N + N) % N;
|
||||
Options::video.scaling_mode = static_cast<Options::ScalingMode>(cur);
|
||||
if (shader_backend_) {
|
||||
shader_backend_->setScaleMode(Options::video.integer_scale);
|
||||
shader_backend_->setScalingMode(Options::video.scaling_mode);
|
||||
} else {
|
||||
applyFallbackPresentation();
|
||||
}
|
||||
@@ -227,10 +230,15 @@ void Screen::toggleVSync() {
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::toggleStretchFilter() {
|
||||
Options::video.stretch_filter_linear = !Options::video.stretch_filter_linear;
|
||||
void Screen::cycleTextureFilter(int dir) {
|
||||
// NEAREST <-> LINEAR (només 2 valors, dir no importa més enllà de canviar)
|
||||
(void)dir;
|
||||
Options::video.texture_filter =
|
||||
(Options::video.texture_filter == Options::TextureFilter::LINEAR)
|
||||
? Options::TextureFilter::NEAREST
|
||||
: Options::TextureFilter::LINEAR;
|
||||
if (shader_backend_) {
|
||||
shader_backend_->setStretchFilter(Options::video.stretch_filter_linear);
|
||||
shader_backend_->setTextureFilter(Options::video.texture_filter);
|
||||
} else {
|
||||
applyFallbackPresentation();
|
||||
}
|
||||
@@ -389,22 +397,27 @@ void Screen::updateRenderInfo() {
|
||||
}
|
||||
|
||||
void Screen::applyFallbackPresentation() {
|
||||
// Fallback SDL_Renderer (p.ex. emscripten/WebGL2 sense shaders GPU): tria
|
||||
// el mode de presentació lògica segons 4:3 i integer_scale, i aplica el
|
||||
// filtre de la textura segons stretch_filter_linear. Sense açò, el path
|
||||
// fallback mostrava sempre LETTERBOX i ignorava les tres flags.
|
||||
SDL_ScaleMode scale = Options::video.stretch_filter_linear ? SDL_SCALEMODE_LINEAR : SDL_SCALEMODE_NEAREST;
|
||||
// Fallback SDL_Renderer (p.ex. emscripten/WebGL2 sense shaders GPU).
|
||||
// Filtre global (texture_filter) s'aplica sempre, independent de 4:3.
|
||||
SDL_ScaleMode scale = (Options::video.texture_filter == Options::TextureFilter::LINEAR)
|
||||
? SDL_SCALEMODE_LINEAR
|
||||
: SDL_SCALEMODE_NEAREST;
|
||||
if (texture_) SDL_SetTextureScaleMode(texture_, scale);
|
||||
|
||||
SDL_RendererLogicalPresentation mode;
|
||||
// Si 4:3 actiu, la finestra ja té aspect 4:3 (alçada × 1.2); STRETCH és
|
||||
// l'única opció viable al path fallback (el GPU path fa l'upscale 4:3 abans
|
||||
// d'escollir el mode de finestra; en fallback no tenim eixa capa intermèdia).
|
||||
SDL_RendererLogicalPresentation mode = SDL_LOGICAL_PRESENTATION_LETTERBOX;
|
||||
if (Options::video.aspect_ratio_4_3) {
|
||||
// La finestra ja té aspect 4:3 (alçada × 1.2); STRETCH estira la
|
||||
// textura 320×200 fins a omplir-la exactament.
|
||||
mode = SDL_LOGICAL_PRESENTATION_STRETCH;
|
||||
} else if (Options::video.integer_scale) {
|
||||
mode = SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
|
||||
} else {
|
||||
mode = SDL_LOGICAL_PRESENTATION_LETTERBOX;
|
||||
switch (Options::video.scaling_mode) {
|
||||
case Options::ScalingMode::DISABLED: mode = SDL_LOGICAL_PRESENTATION_DISABLED; break;
|
||||
case Options::ScalingMode::STRETCH: mode = SDL_LOGICAL_PRESENTATION_STRETCH; break;
|
||||
case Options::ScalingMode::LETTERBOX: mode = SDL_LOGICAL_PRESENTATION_LETTERBOX; break;
|
||||
case Options::ScalingMode::OVERSCAN: mode = SDL_LOGICAL_PRESENTATION_OVERSCAN; break;
|
||||
case Options::ScalingMode::INTEGER: mode = SDL_LOGICAL_PRESENTATION_INTEGER_SCALE; break;
|
||||
}
|
||||
}
|
||||
SDL_SetRenderLogicalPresentation(renderer_, GAME_WIDTH, GAME_HEIGHT, mode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user