diff options
-rw-r--r-- | src/library_html5.js | 6 | ||||
-rw-r--r-- | system/include/emscripten/html5.h | 6 |
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 |