opcions per defecte d'emscripten
This commit is contained in:
@@ -42,10 +42,9 @@ Screen::Screen() {
|
||||
|
||||
window_ = SDL_CreateWindow(Locale::get("window.title"), w, h, fullscreen_ ? SDL_WINDOW_FULLSCREEN : 0);
|
||||
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
||||
SDL_SetRenderLogicalPresentation(renderer_, GAME_WIDTH, GAME_HEIGHT, SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||
|
||||
texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, GAME_WIDTH, GAME_HEIGHT);
|
||||
SDL_SetTextureScaleMode(texture_, SDL_SCALEMODE_NEAREST);
|
||||
applyFallbackPresentation();
|
||||
|
||||
// Inicialitza backend GPU si l'acceleració està activada
|
||||
initShaders();
|
||||
@@ -204,6 +203,8 @@ void Screen::toggleAspectRatio() {
|
||||
Options::video.aspect_ratio_4_3 = !Options::video.aspect_ratio_4_3;
|
||||
if (shader_backend_) {
|
||||
shader_backend_->setStretch4_3(Options::video.aspect_ratio_4_3);
|
||||
} else {
|
||||
applyFallbackPresentation();
|
||||
}
|
||||
if (!fullscreen_) {
|
||||
adjustWindowSize();
|
||||
@@ -214,6 +215,8 @@ void Screen::toggleIntegerScale() {
|
||||
Options::video.integer_scale = !Options::video.integer_scale;
|
||||
if (shader_backend_) {
|
||||
shader_backend_->setScaleMode(Options::video.integer_scale);
|
||||
} else {
|
||||
applyFallbackPresentation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,6 +231,8 @@ void Screen::toggleStretchFilter() {
|
||||
Options::video.stretch_filter_linear = !Options::video.stretch_filter_linear;
|
||||
if (shader_backend_) {
|
||||
shader_backend_->setStretchFilter(Options::video.stretch_filter_linear);
|
||||
} else {
|
||||
applyFallbackPresentation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,6 +388,27 @@ void Screen::updateRenderInfo() {
|
||||
0b1001);
|
||||
}
|
||||
|
||||
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;
|
||||
if (texture_) SDL_SetTextureScaleMode(texture_, scale);
|
||||
|
||||
SDL_RendererLogicalPresentation mode;
|
||||
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;
|
||||
}
|
||||
SDL_SetRenderLogicalPresentation(renderer_, GAME_WIDTH, GAME_HEIGHT, mode);
|
||||
}
|
||||
|
||||
void Screen::adjustWindowSize() {
|
||||
int w = GAME_WIDTH * zoom_;
|
||||
// Si 4:3 actiu, l'alçada visual és 240 per zoom (200 * 1.2)
|
||||
|
||||
Reference in New Issue
Block a user