PDA

View Full Version : how to fix your library_openal.js for emscripten 1.37.21



kung foo man
19th May 2018, 15:00
I would love to use the latest emscripten version, but their current library_openal.js is fucked up. They have largely rewritten it and ended up recalculating stuff in JavaScript with lots of Math.sqrt(...)

The result of that is that it makes libwebgame unplayable, the frame rate is like 20fps + lots of strange sound bugs. The Performance Profiler in Chrome shows like 20ms per frame in that shitty sound function full of matrix recalculations and Math.sqrt(...)

The old library_openal.js didn't work out-of-house though too (which might be the reason why the rewrote it, no clue), but I figured this setter/getter bug out, just a bit annoying to fix it for each emscripten installation:


https://www.youtube.com/watch?v=3Xqb1D93r04

Around line 653, patch the switch code with this:



switch (param) {
case 0x1004 /* AL_POSITION */: src.position = [v1, v2, v3]; break;
case 0x1005 /* AL_DIRECTION */: src.direction = [v1, v2, v3]; break;
case 0x1006 /* AL_VELOCITY */: src.velocity = [v1, v2, v3]; break;
default:
#if OPENAL_DEBUG
console.log("alSource3f with param " + param + " not implemented yet");
#endif
AL.currentContext.err = 0xA002 /* AL_INVALID_ENUM */;
break;
}