summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/deps_info.json1
-rw-r--r--src/library.js1
-rw-r--r--src/library_browser.js33
-rw-r--r--src/library_glfw.js7
-rw-r--r--src/library_sdl.js2
-rw-r--r--src/preamble.js2
6 files changed, 42 insertions, 4 deletions
diff --git a/src/deps_info.json b/src/deps_info.json
index 029a20e1..e0983064 100644
--- a/src/deps_info.json
+++ b/src/deps_info.json
@@ -3,6 +3,7 @@
"SDL_Init": ["malloc", "free"],
"SDL_GL_GetProcAddress": ["emscripten_GetProcAddress"],
"eglGetProcAddress": ["emscripten_GetProcAddress"],
+ "glfwGetProcAddress": ["emscripten_GetProcAddress"],
"emscripten_GetProcAddress": ["strstr"]
}
diff --git a/src/library.js b/src/library.js
index 120def05..c17952b3 100644
--- a/src/library.js
+++ b/src/library.js
@@ -3353,6 +3353,7 @@ LibraryManager.library = {
return 0;
} else {
var size = Math.min(4095, absolute.path.length); // PATH_MAX - 1.
+ if (resolved_name === 0) resolved_name = _malloc(size+1);
for (var i = 0; i < size; i++) {
{{{ makeSetValue('resolved_name', 'i', 'absolute.path.charCodeAt(i)', 'i8') }}};
}
diff --git a/src/library_browser.js b/src/library_browser.js
index 4ef7c577..57ca5a24 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -1175,6 +1175,39 @@ mergeInto(LibraryManager.library, {
var info = Browser.workers[id];
if (!info) return -1;
return info.awaited;
+ },
+
+ emscripten_get_preloaded_image_data: function(path, w, h) {
+ if (typeof path === "number") {
+ path = Pointer_stringify(path);
+ }
+
+ path = PATH.resolve(path);
+
+ var canvas = Module["preloadedImages"][path];
+ if (canvas) {
+ var ctx = canvas.getContext("2d");
+ var image = ctx.getImageData(0, 0, canvas.width, canvas.height);
+ var buf = _malloc(canvas.width * canvas.height * 4);
+
+ HEAPU8.set(image.data, buf);
+
+ {{{ makeSetValue('w', '0', 'canvas.width', 'i32') }}};
+ {{{ makeSetValue('h', '0', 'canvas.height', 'i32') }}};
+ return buf;
+ }
+
+ return 0;
+ },
+
+ emscripten_get_preloaded_image_data_from_FILE__deps: ['emscripten_get_preloaded_image_data'],
+ emscripten_get_preloaded_image_data_from_FILE: function(file, w, h) {
+ var stream = FS.getStreamFromPtr(file);
+ if (stream) {
+ return _emscripten_get_preloaded_image_data(stream.path, w, h);
+ }
+
+ return 0;
}
});
diff --git a/src/library_glfw.js b/src/library_glfw.js
index 6d539326..6dfea101 100644
--- a/src/library_glfw.js
+++ b/src/library_glfw.js
@@ -417,6 +417,9 @@ var LibraryGLFW = {
glfwSetWindowSizeCallback: function(cbfun) {
GLFW.resizeFunc = cbfun;
+ if (GLFW.resizeFunc) {
+ Runtime.dynCall('vii', GLFW.resizeFunc, [Module['canvas'].width, Module['canvas'].height]);
+ }
},
glfwSetWindowCloseCallback: function(cbfun) {
@@ -507,9 +510,9 @@ var LibraryGLFW = {
return Module.ctx.getSupportedExtensions().indexOf(Pointer_stringify(extension)) > -1;
},
- glfwGetProcAddress__deps: ['glfwGetProcAddress'],
+ glfwGetProcAddress__deps: ['emscripten_GetProcAddress'],
glfwGetProcAddress: function(procname) {
- return _getProcAddress(procname);
+ return _emscripten_GetProcAddress(procname);
},
glfwGetGLVersion: function(major, minor, rev) {
diff --git a/src/library_sdl.js b/src/library_sdl.js
index a01b3c6c..7145a7ba 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -2601,7 +2601,7 @@ var LibrarySDL = {
if (info && info.audio) {
info.audio.pause();
} else {
- Module.printErr('Mix_Pause: no sound found for channel: ' + channel);
+ //Module.printErr('Mix_Pause: no sound found for channel: ' + channel);
}
},
diff --git a/src/preamble.js b/src/preamble.js
index 431a3c27..ae58e7e0 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -401,7 +401,7 @@ var cwrap, ccall;
return ret;
}
- var sourceRegex = /^function\s\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
+ var sourceRegex = /^function\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
function parseJSFunc(jsfunc) {
// Match the body and the return value of a javascript function source
var parsed = jsfunc.toString().match(sourceRegex).slice(1);