OPENGL EMSCRIPTEN: clean up ifdefs, fix opengl in main menu, remove 10ms delay in GRIM main loop

This commit is contained in:
Christian Kündig 2021-06-07 15:05:48 +02:00 committed by Eugene Sandulenko
parent 7c4fdc1b94
commit 8af8ac2e08
4 changed files with 10 additions and 12 deletions

View file

@ -180,8 +180,9 @@ void OpenGLSdlGraphics3dManager::setupScreen() {
// So check if the window needs to be recreated.
int currentSamples = 0;
#if defined(EMSCRIPTEN)
// SDL_GL_MULTISAMPLESAMPLES isn't available on the WebGL context (or not bridged in Emscripten?), let's just reset the windows every time
#if defined(__EMSCRIPTEN__)
// SDL_GL_MULTISAMPLESAMPLES isn't available on a WebGL 1.0 context
// (or not bridged in Emscripten?). This forces a windows reset.
currentSamples = -1;
#else
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &currentSamples);

3
configure vendored
View file

@ -2913,9 +2913,8 @@ EOF
append_var LIBS "-lnds9"
;;
emscripten)
add_line_to_config_mk 'EMSCRIPTEN = 1'
# mandatory emscripten flags
append_var LDFLAGS "-s MAX_WEBGL_VERSION=2 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s ASYNCIFY -s FORCE_FILESYSTEM=1 -s ALLOW_MEMORY_GROWTH=1"
append_var LDFLAGS "-s FULL_ES2=1 -s MAX_WEBGL_VERSION=1 -s ASYNCIFY -s FORCE_FILESYSTEM=1 -s ALLOW_MEMORY_GROWTH=1"
# enable emscripten-ports and set up paths accordingly
append_var LDFLAGS "-s USE_SDL=2 -s USE_SDL_MIXER=2 -s USE_OGG=1 -s USE_VORBIS=1 -s USE_LIBJPEG=1 -s USE_FREETYPE=1 -s USE_ZLIB"
_sdlpath="$EMSDK/upstream/emscripten/system/bin/"

View file

@ -1116,10 +1116,13 @@ void GrimEngine::mainLoop() {
g_imuseState = -1;
}
#if defined(EMSCRIPTEN)
// We need to yield regularly to unblock the main thread
g_system->delayMillis(10);
#if defined(__EMSCRIPTEN__)
// If SDL_HINT_EMSCRIPTEN_ASYNCIFY is enabled, SDL pauses the application and gives
// back control to the browser automatically by calling emscripten_sleep via SDL_Delay.
// Without this the page would completely lock up.
g_system->delayMillis(0);
#endif
uint32 endTime = g_system->getMillis();
if (startTime > endTime)
continue;

View file

@ -33,9 +33,6 @@ namespace OpenGL {
static const GLchar *readFile(const Common::String &filename) {
Common::File file;
#if defined(EMSCRIPTEN)
// Since we need to bundle all files into data files on Emscripten, we keep all shaders in a different folder
#endif
// Allow load shaders from source code directory without install them
// It's used for development purpose
// FIXME: it's doesn't work with just search subdirs in 'engines'
@ -50,8 +47,6 @@ static const GLchar *readFile(const Common::String &filename) {
SearchMan.remove("MYST3_SHADERS");
SearchMan.remove("STARK_SHADERS");
SearchMan.remove("WINTERMUTE_SHADERS");
#if defined(EMSCRIPTEN)
#endif
const int32 size = file.size();
GLchar *shaderSource = new GLchar[size + 1];