#include "Environment.h" #include "utils/Utils.h" #ifdef __ANDROID__ #include #include #else #include #endif #ifdef EMSCRIPTEN #include #endif namespace FRG { int Environment::windowHeaderHeight = 0; int Environment::width = CONST_DEFAULT_WIDTH; int Environment::height = CONST_DEFAULT_HEIGHT; float Environment::zoom = DEFAULT_ZOOM; bool Environment::enableLogging = false; //bool Environment::enableLogging = true; SDL_Window* Environment::window = nullptr; #ifdef EMSCRIPTEN bool Environment::isFullscreen = false; #else bool Environment::isFullscreen = true; #endif bool Environment::isHighDPIEnabled = false; int Environment::customDpiScale = 1; bool Environment::showMouse = false; bool Environment::exitGameLoop = false; Eigen::Matrix3f Environment::inverseShipMatrix = Eigen::Matrix3f::Identity(); bool Environment::tapDownHold = false; Eigen::Vector2f Environment::tapDownStartPos = { 0, 0 }; Eigen::Vector2f Environment::tapDownCurrentPos = { 0, 0 }; const float Environment::CONST_Z_NEAR = 0.1f; const float Environment::CONST_Z_FAR = 100.f; float Environment::projectionWidth = 1280.0f; float Environment::projectionHeight = 720.0f; void Environment::computeProjectionDimensions() { if (width <= 0 || height <= 0) return; const float refShortSide = 720.0f; float aspect = (float)width / (float)height; if (width >= height) { // Landscape: fix height to 720, scale width to preserve aspect projectionHeight = refShortSide; projectionWidth = refShortSide * aspect; } else { // Portrait: fix width to 720, scale height to preserve aspect projectionWidth = refShortSide; projectionHeight = refShortSide / aspect; } } void Environment::setFullscreen(bool enable) { #ifdef EMSCRIPTEN if (enable) { EmscriptenFullscreenStrategy strategy{}; strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; emscripten_request_fullscreen_strategy("#canvas", EM_TRUE, &strategy); } else { emscripten_exit_fullscreen(); } // isFullscreen is updated by onFullscreenChanged once the browser confirms — // the request above is deferred/async and can fail silently (e.g. denied). #else if (window) { SDL_SetWindowFullscreen(window, enable ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); } isFullscreen = enable; #endif } } // namespace FRG