[web] Fix Emscripten's Closure compiler error: undeclared canvas variable (#5507)
* Fix Emscripten Closure compiler error: undeclared canvas variable * Fix hardcoded canvas IDs in web targets
This commit is contained in:
parent
a33ae4a8ef
commit
70a63f7c62
|
|
@ -316,15 +316,16 @@ void ToggleBorderlessWindowed(void)
|
||||||
// 2. The style unset handles the possibility of a width="value%" like on the default shell.html file
|
// 2. The style unset handles the possibility of a width="value%" like on the default shell.html file
|
||||||
EM_ASM
|
EM_ASM
|
||||||
(
|
(
|
||||||
|
const canvasId = UTF8ToString($0);
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
Module.requestFullscreen(false, true);
|
Module.requestFullscreen(false, true);
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
canvas.style.width="unset";
|
document.querySelector(canvasId).style.width="unset";
|
||||||
}, 100);
|
}, 100);
|
||||||
}, 100);
|
}, 100);
|
||||||
);
|
, platform.canvasId);
|
||||||
FLAG_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE);
|
FLAG_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1238,9 +1239,9 @@ int InitPlatform(void)
|
||||||
// Avoid creating a WebGL canvas, avoid calling glfwCreateWindow()
|
// Avoid creating a WebGL canvas, avoid calling glfwCreateWindow()
|
||||||
emscripten_set_canvas_element_size(platform.canvasId, CORE.Window.screen.width, CORE.Window.screen.height);
|
emscripten_set_canvas_element_size(platform.canvasId, CORE.Window.screen.width, CORE.Window.screen.height);
|
||||||
EM_ASM({
|
EM_ASM({
|
||||||
const canvas = document.getElementById("canvas");
|
const canvas = document.querySelector(UTF8ToString($0));
|
||||||
Module.canvas = canvas;
|
Module.canvas = canvas;
|
||||||
});
|
}, platform.canvasId);
|
||||||
|
|
||||||
// Load memory framebuffer with desired screen size
|
// Load memory framebuffer with desired screen size
|
||||||
// NOTE: Despite using a software framebuffer for blitting, GLFW still creates a WebGL canvas,
|
// NOTE: Despite using a software framebuffer for blitting, GLFW still creates a WebGL canvas,
|
||||||
|
|
|
||||||
|
|
@ -280,15 +280,16 @@ void ToggleBorderlessWindowed(void)
|
||||||
// 2. The style unset handles the possibility of a width="value%" like on the default shell.html file
|
// 2. The style unset handles the possibility of a width="value%" like on the default shell.html file
|
||||||
EM_ASM
|
EM_ASM
|
||||||
(
|
(
|
||||||
|
const canvasId = UTF8ToString($0);
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
Module.requestFullscreen(false, true);
|
Module.requestFullscreen(false, true);
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
canvas.style.width="unset";
|
document.querySelector(canvasId).style.width="unset";
|
||||||
}, 100);
|
}, 100);
|
||||||
}, 100);
|
}, 100);
|
||||||
);
|
, platform.canvasId);
|
||||||
FLAG_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE);
|
FLAG_SET(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user