impr: Prevent canvas flickering in web build
This commit is contained in:
parent
2cd8b13c1d
commit
60b81e714b
12
dist/web/source/wasm-config.js
vendored
12
dist/web/source/wasm-config.js
vendored
@ -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();
|
|
||||||
}
|
}
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user