aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2014-05-12 15:26:34 +0300
committerJukka Jylänki <jujjyl@gmail.com>2014-05-12 15:29:40 +0300
commit7fa0bdd051b174ed2487181812c5fc34a001d7c0 (patch)
tree37f9bdcd5fb0e98d02989c14ef0b4b671f440dd8
parentd76259d08d6e93bed247c2158fcb3740ed4c2dcd (diff)
Add new function emscripten_is_webgl_context_lost() that allows code to directly query to confirm the WebGL context loss status.
-rw-r--r--src/library_html5.js6
-rw-r--r--system/include/emscripten/html5.h6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/library_html5.js b/src/library_html5.js
index d9376c2a..d5d0cd66 100644
--- a/src/library_html5.js
+++ b/src/library_html5.js
@@ -1307,6 +1307,12 @@ var LibraryJSEvents = {
JSEvents.registerWebGlEventCallback(target, userData, useCapture, callbackfunc, {{{ cDefine('EMSCRIPTEN_EVENT_WEBGLCONTEXTRESTORED') }}}, "webglcontextrestored");
return {{{ cDefine('EMSCRIPTEN_RESULT_SUCCESS') }}};
},
+
+ emscripten_is_webgl_context_lost: function(target) {
+ // TODO: In the future if multiple GL contexts are supported, use the 'target' parameter to find the canvas to query.
+ if (!Module['ctx']) return true; // No context ~> lost context.
+ return Module['ctx'].isContextLost();
+ }
};
autoAddDeps(LibraryJSEvents, '$JSEvents');
diff --git a/system/include/emscripten/html5.h b/system/include/emscripten/html5.h
index db81725a..74c32a99 100644
--- a/system/include/emscripten/html5.h
+++ b/system/include/emscripten/html5.h
@@ -636,6 +636,12 @@ extern EMSCRIPTEN_RESULT emscripten_set_beforeunload_callback(void *userData, co
extern EMSCRIPTEN_RESULT emscripten_set_webglcontextlost_callback(const char *target, void *userData, int useCapture, EM_BOOL (*func)(int eventType, const void *reserved, void *userData));
extern EMSCRIPTEN_RESULT emscripten_set_webglcontextrestored_callback(const char *target, void *userData, int useCapture, EM_BOOL (*func)(int eventType, const void *reserved, void *userData));
+/*
+ * Queries the given canvas element for whether its WebGL context is in a lost state.
+ * target: Reserved for future use, pass in 0.
+ */
+extern EM_BOOL emscripten_is_webgl_context_lost(const char *target);
+
#ifdef __cplusplus
} // ~extern "C"
#endif