emscripten: wasm64 fixes (thanks, jsm174!).

Fixes #16635.
This commit is contained in:
Ryan C. Gordon
2026-11-02 12:45:35 -05:00
parent 133153507f
commit b1eb76ec27
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -359,7 +359,7 @@ bool SDL_InitSubSystem(SDL_InitFlags flags)
if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return ptr >>> 2; }; }
#elif defined(__wasm64__)
if (typeof(SDL3.JSVarToCPtr) === 'undefined') { SDL3.JSVarToCPtr = function(v) { return BigInt(v); }; }
if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return Number(ptr / 4n); }; }
if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return Math.floor(Number(ptr) / 4); }; }
#else
#error Please define your platform.
#endif
+3 -1
View File
@@ -797,7 +797,9 @@ static bool Emscripten_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window,
MAIN_THREAD_EM_ASM({
// Use `.slice` to make a copy of the data if we are dealing with a SharedArrayBuffer, or `.subarray` to create a
// view into the existing buffer if its non-shared.
var pngData = HEAPU8.buffer instanceof ArrayBuffer ? HEAPU8.subarray($0, $0 + $1) : HEAPU8.slice($0, $0 + $1);
var ptr = Number($0);
var len = Number($1);
var pngData = HEAPU8.buffer instanceof ArrayBuffer ? HEAPU8.subarray(ptr, ptr + len) : HEAPU8.slice(ptr, ptr + len);
var blob = new Blob([pngData], {type: 'image/png'});
var url = URL.createObjectURL(blob);