afegit suport Emscripten/WebAssembly al build system

- CMakeLists.txt: branca EMSCRIPTEN amb SDL3 via FetchContent, preload de data/
  config/ i gamecontrollerdb.txt, WebGL2, EMSCRIPTEN_BUILD define i sortida .html.
  Exclou sdl3gpu_shader (no soportat a WebGL2) i el pack_tool en wasm.
- Makefile: target wasm via Docker emscripten/emsdk, build a build/wasm i
  sortida a dist/wasm (.html .js .wasm .data).
- director.cpp: createSystemFolder utilitza MEMFS en wasm (sense pwd.h/unistd.h),
  executable_path buit, dev-mode forçat (filesystem preload, no pack), windowed.
- screen.cpp: initShaders és no-op en wasm (SDL3 GPU no suportat a WebGL2).
- global_inputs.cpp: handleQuit és no-op en wasm (no es pot eixir del joc).
- Director::handleEvent ignora SDL_EVENT_QUIT en wasm.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 09:02:00 +02:00
parent c32a880b6a
commit 70cfe5245d
5 changed files with 124 additions and 37 deletions

View File

@@ -13,7 +13,9 @@
#include "core/input/mouse.hpp" // Para updateCursorVisibility
#include "core/rendering/render_info.hpp" // Para RenderInfo
#include "core/rendering/sdl3gpu/sdl3gpu_shader.hpp" // Para SDL3GPUShader
#ifndef __EMSCRIPTEN__
#include "core/rendering/sdl3gpu/sdl3gpu_shader.hpp" // Para SDL3GPUShader (no suportat a WebGL2)
#endif
#include "core/rendering/surface.hpp" // Para Surface, readPalFile
#include "core/rendering/text.hpp" // Para Text
#include "core/resources/resource_cache.hpp" // Para Resource
@@ -605,6 +607,10 @@ void Screen::nextShader() {
// El device GPU se crea siempre (independientemente de postfx) para evitar
// conflictos SDL_Renderer/SDL_GPU al hacer toggle F4 en Windows/Vulkan.
void Screen::initShaders() {
#ifdef __EMSCRIPTEN__
// A WebGL2 no hi ha SDL3 GPU, el render va per SDL_Renderer sense shaders.
shader_backend_.reset();
#else
SDL_Texture* tex = Options::video.border.enabled ? border_texture_ : game_texture_;
if (!shader_backend_) {
@@ -633,6 +639,7 @@ void Screen::initShaders() {
if (Options::video.shader.current_shader == Rendering::ShaderType::CRTPI) {
applyCurrentCrtPiPreset();
}
#endif
}
// Obtiene información sobre la pantalla