Skip to content

Commit

Permalink
sokol_app.h html5: allow to initialize canvas from Module['canvas']
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Nov 22, 2024
1 parent 554e777 commit 05190b6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -5015,6 +5015,12 @@ EM_JS(void, sapp_js_remove_dragndrop_listeners, (void), {

EM_JS(void, sapp_js_init, (const char* c_str_target_selector), {
const target_selector_str = UTF8ToString(c_str_target_selector);
// check if canvas is provided via Module['canvas'], if yes make it visible
// in specialHTMLTargets[], this is an additional way to inject a canvas into
// sokol_app.h when it can't be found via document.querySelector()
if (Module['canvas']) {
specialHTMLTargets[target_selector_str] = Module['canvas'];
}
Module.sapp_emsc_target = findCanvasEventTarget(target_selector_str);
if (!Module.sapp_emsc_target) {
console.log("sokol_app.h: invalid target selector:" + target_selector_str);
Expand Down

0 comments on commit 05190b6

Please sign in to comment.