forked from SuperTux/supertux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- The MSVC bug from the parent commit wasn't a macro, apparently - Forgot to commit src/port/emscripten.cpp - Emscripten doesn't support LTO very well, disable it for now
- Loading branch information
Semphris
committed
Jun 17, 2024
1 parent
390137b
commit 42c777c
Showing
3 changed files
with
98 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// SuperTux | ||
// Copyright (C) 2021 A. Semphris <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#include "port/emscripten.hpp" | ||
|
||
#ifdef __EMSCRIPTEN__ | ||
|
||
extern "C" { | ||
|
||
EMSCRIPTEN_KEEPALIVE // This is probably not useful, I just want ppl to know it exists | ||
void | ||
set_resolution(int w, int h) | ||
{ | ||
VideoSystem::current()->on_resize(w, h); | ||
MenuManager::instance().on_window_resize(); | ||
} | ||
|
||
EMSCRIPTEN_KEEPALIVE // Same as above | ||
void | ||
save_config() | ||
{ | ||
g_config->save(); | ||
} | ||
|
||
void | ||
onDownloadProgress(int id, int loaded, int total) | ||
{ | ||
AddonManager::current()->onDownloadProgress(id, loaded, total); | ||
} | ||
|
||
void | ||
onDownloadFinished(int id) | ||
{ | ||
AddonManager::current()->onDownloadFinished(id); | ||
} | ||
|
||
void | ||
onDownloadError(int id) | ||
{ | ||
AddonManager::current()->onDownloadError(id); | ||
} | ||
|
||
void | ||
onDownloadAborted(int id) | ||
{ | ||
AddonManager::current()->onDownloadAborted(id); | ||
} | ||
|
||
const char* | ||
getExceptionMessage(intptr_t address) | ||
{ | ||
return reinterpret_cast<std::exception*>(address)->what(); | ||
} | ||
|
||
} // extern "C" | ||
|
||
void | ||
init_emscripten() | ||
{ | ||
EM_ASM({ | ||
if (window.supertux_onready) | ||
window.supertux_onready(); | ||
}, 0); // EM_ASM is a variadic macro and Clang requires at least 1 value for the variadic argument | ||
} | ||
|
||
#endif |