mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 10:31:16 +00:00
Disable offscreen canvases in case of no WebGL support (#559)
This commit is contained in:
parent
2761d9985a
commit
37c6abe3b5
@ -532,6 +532,7 @@ if (ISLE_BUILD_APP)
|
|||||||
endif()
|
endif()
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
target_sources(isle PRIVATE
|
target_sources(isle PRIVATE
|
||||||
|
ISLE/emscripten/config.cpp
|
||||||
ISLE/emscripten/events.cpp
|
ISLE/emscripten/events.cpp
|
||||||
ISLE/emscripten/filesystem.cpp
|
ISLE/emscripten/filesystem.cpp
|
||||||
ISLE/emscripten/messagebox.cpp
|
ISLE/emscripten/messagebox.cpp
|
||||||
|
|||||||
17
ISLE/emscripten/config.cpp
Normal file
17
ISLE/emscripten/config.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "filesystem.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_log.h>
|
||||||
|
#include <iniparser.h>
|
||||||
|
|
||||||
|
void Emscripten_SetupDefaultConfigOverrides(dictionary* p_dictionary)
|
||||||
|
{
|
||||||
|
SDL_Log("Overriding default config for Emscripten");
|
||||||
|
|
||||||
|
iniparser_set(p_dictionary, "isle:diskpath", Emscripten_bundledPath);
|
||||||
|
iniparser_set(p_dictionary, "isle:cdpath", Emscripten_streamPath);
|
||||||
|
iniparser_set(p_dictionary, "isle:savepath", Emscripten_savePath);
|
||||||
|
iniparser_set(p_dictionary, "isle:Full Screen", "false");
|
||||||
|
iniparser_set(p_dictionary, "isle:Flip Surfaces", "true");
|
||||||
|
}
|
||||||
8
ISLE/emscripten/config.h
Normal file
8
ISLE/emscripten/config.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef EMSCRIPTEN_CONFIG_H
|
||||||
|
#define EMSCRIPTEN_CONFIG_H
|
||||||
|
|
||||||
|
#include "dictionary.h"
|
||||||
|
|
||||||
|
void Emscripten_SetupDefaultConfigOverrides(dictionary* p_dictionary);
|
||||||
|
|
||||||
|
#endif // EMSCRIPTEN_CONFIG_H
|
||||||
@ -140,20 +140,26 @@ index e8c9f7e21..caf1971d2 100644
|
|||||||
-
|
-
|
||||||
});
|
});
|
||||||
diff --git a/src/preamble.js b/src/preamble.js
|
diff --git a/src/preamble.js b/src/preamble.js
|
||||||
index 572694517..0d2f4421b 100644
|
index 572694517..44e65c823 100644
|
||||||
--- a/src/preamble.js
|
--- a/src/preamble.js
|
||||||
+++ b/src/preamble.js
|
+++ b/src/preamble.js
|
||||||
@@ -1062,3 +1062,13 @@ function getCompilerSetting(name) {
|
@@ -1062,3 +1062,19 @@ function getCompilerSetting(name) {
|
||||||
// dynamic linker as symbols are loaded.
|
// dynamic linker as symbols are loaded.
|
||||||
var asyncifyStubs = {};
|
var asyncifyStubs = {};
|
||||||
#endif
|
#endif
|
||||||
+
|
+
|
||||||
+(async () => {
|
+if (typeof document !== "undefined") {
|
||||||
+ try {
|
+ (async () => {
|
||||||
+ await navigator.storage.getDirectory();
|
+ try {
|
||||||
+ Module["disableOpfs"] = false;
|
+ await navigator.storage.getDirectory();
|
||||||
+ } catch (e) {
|
+ Module["disableOpfs"] = false;
|
||||||
+ Module["disableOpfs"] = true;
|
+ } catch (e) {
|
||||||
+ }
|
+ Module["disableOpfs"] = true;
|
||||||
+})();
|
+ }
|
||||||
|
+ console.log("disableOpfs: " + Module["disableOpfs"]);
|
||||||
|
+ })();
|
||||||
|
+
|
||||||
|
+ Module["disableOffscreenCanvases"] ||= !document.createElement('canvas').getContext('webgl');
|
||||||
|
+ console.log("disableOffscreenCanvases: " + Module["disableOffscreenCanvases"]);
|
||||||
|
+}
|
||||||
+
|
+
|
||||||
|
|||||||
@ -48,6 +48,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include "emscripten/config.h"
|
||||||
#include "emscripten/events.h"
|
#include "emscripten/events.h"
|
||||||
#include "emscripten/filesystem.h"
|
#include "emscripten/filesystem.h"
|
||||||
#include "emscripten/messagebox.h"
|
#include "emscripten/messagebox.h"
|
||||||
@ -1003,19 +1004,15 @@ bool IsleApp::LoadConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
const char* hdPath = Emscripten_bundledPath;
|
Emscripten_SetupDefaultConfigOverrides(dict);
|
||||||
#else
|
|
||||||
const char* hdPath = iniparser_getstring(dict, "isle:diskpath", SDL_GetBasePath());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char* hdPath = iniparser_getstring(dict, "isle:diskpath", SDL_GetBasePath());
|
||||||
m_hdPath = new char[strlen(hdPath) + 1];
|
m_hdPath = new char[strlen(hdPath) + 1];
|
||||||
strcpy(m_hdPath, hdPath);
|
strcpy(m_hdPath, hdPath);
|
||||||
MxOmni::SetHD(m_hdPath);
|
MxOmni::SetHD(m_hdPath);
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
const char* cdPath = Emscripten_streamPath;
|
|
||||||
#else
|
|
||||||
const char* cdPath = iniparser_getstring(dict, "isle:cdpath", MxOmni::GetCD());
|
const char* cdPath = iniparser_getstring(dict, "isle:cdpath", MxOmni::GetCD());
|
||||||
#endif
|
|
||||||
m_cdPath = new char[strlen(cdPath) + 1];
|
m_cdPath = new char[strlen(cdPath) + 1];
|
||||||
strcpy(m_cdPath, cdPath);
|
strcpy(m_cdPath, cdPath);
|
||||||
MxOmni::SetCD(m_cdPath);
|
MxOmni::SetCD(m_cdPath);
|
||||||
@ -1025,13 +1022,7 @@ bool IsleApp::LoadConfig()
|
|||||||
strcpy(m_mediaPath, mediaPath);
|
strcpy(m_mediaPath, mediaPath);
|
||||||
|
|
||||||
m_flipSurfaces = iniparser_getboolean(dict, "isle:Flip Surfaces", m_flipSurfaces);
|
m_flipSurfaces = iniparser_getboolean(dict, "isle:Flip Surfaces", m_flipSurfaces);
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
m_fullScreen = FALSE;
|
|
||||||
#else
|
|
||||||
m_fullScreen = iniparser_getboolean(dict, "isle:Full Screen", m_fullScreen);
|
m_fullScreen = iniparser_getboolean(dict, "isle:Full Screen", m_fullScreen);
|
||||||
#endif
|
|
||||||
|
|
||||||
m_wideViewAngle = iniparser_getboolean(dict, "isle:Wide View Angle", m_wideViewAngle);
|
m_wideViewAngle = iniparser_getboolean(dict, "isle:Wide View Angle", m_wideViewAngle);
|
||||||
m_use3dSound = iniparser_getboolean(dict, "isle:3DSound", m_use3dSound);
|
m_use3dSound = iniparser_getboolean(dict, "isle:3DSound", m_use3dSound);
|
||||||
m_useMusic = iniparser_getboolean(dict, "isle:Music", m_useMusic);
|
m_useMusic = iniparser_getboolean(dict, "isle:Music", m_useMusic);
|
||||||
@ -1071,11 +1062,7 @@ bool IsleApp::LoadConfig()
|
|||||||
// [library:config]
|
// [library:config]
|
||||||
// The original game does not save any data if no savepath is given.
|
// The original game does not save any data if no savepath is given.
|
||||||
// Instead, we use SDLs prefPath as a default fallback and always save data.
|
// Instead, we use SDLs prefPath as a default fallback and always save data.
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
const char* savePath = Emscripten_savePath;
|
|
||||||
#else
|
|
||||||
const char* savePath = iniparser_getstring(dict, "isle:savepath", prefPath);
|
const char* savePath = iniparser_getstring(dict, "isle:savepath", prefPath);
|
||||||
#endif
|
|
||||||
m_savePath = new char[strlen(savePath) + 1];
|
m_savePath = new char[strlen(savePath) + 1];
|
||||||
strcpy(m_savePath, savePath);
|
strcpy(m_savePath, savePath);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user