1
0
mirror of synced 2024-11-30 18:34:29 +01:00

impr: Prevent canvas flickering in web build

This commit is contained in:
WerWolv 2024-07-01 20:09:16 +02:00
parent 2cd8b13c1d
commit 60b81e714b
3 changed files with 7 additions and 9 deletions

View File

@ -144,14 +144,10 @@ if (urlParams.has("lang")) {
window.addEventListener('resize', js_resizeCanvas, false); window.addEventListener('resize', js_resizeCanvas, false);
function js_resizeCanvas() { function js_resizeCanvas() {
let canvas = document.getElementById('canvas'); let canvas = document.getElementById('canvas');
canvas.top = document.documentElement.clientTop;
canvas.left = document.documentElement.clientLeft;
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 0); canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 0);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 0); canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 0);
canvas.classList.add("canvas_full_screen")
if (GLFW.active && GLFW.active.windowPosFunc) {
getWasmTableEntry(GLFW.active.windowPosFunc)(GLFW.active.id, GLFW.active.x, GLFW.active.y);
}
GLFW.onWindowSizeChanged();
} }

View File

@ -87,6 +87,7 @@ namespace hex {
glfwSetWindowRefreshCallback(m_window, [](GLFWwindow *window) { glfwSetWindowRefreshCallback(m_window, [](GLFWwindow *window) {
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window)); auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
resizeCanvas();
win->fullFrame(); win->fullFrame();
}); });

View File

@ -844,7 +844,8 @@ namespace hex {
if (macosIsWindowBeingResizedByUser(window)) { if (macosIsWindowBeingResizedByUser(window)) {
ImGui::GetIO().MousePos = ImVec2(); ImGui::GetIO().MousePos = ImVec2();
} }
#else #elif defined(OS_WEB)
win->fullFrame();
#endif #endif
}); });