Skip to content

Commit 8228497

Browse files
committed
Fix wasm64 runtime exception for imgui glfw backend
1 parent c12a1b5 commit 8228497

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

extensions/ImGui/src/ImGui/imgui_impl_ax.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,14 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
674674
// GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting.
675675
// Missing cursors will return nullptr and our _UpdateMouseCursor() function will use the Arrow cursor instead.)
676676
GLFWerrorfun prev_error_callback = glfwSetErrorCallback(nullptr);
677+
678+
// axmol spec: Fix wasm64 javascript exception
679+
// Note: The WASM actually not support glfwCreateStandardCursor until emsdk-4.0.1 Jan.17 2025
680+
// Uncaught TypeError: Cannot convert undefined to a BigInt
681+
// at BigInt (<anonymous>)
682+
// at _glfwCreateStandardCursor (http://localhost:6931/cpp-tests.js:16617:12)
683+
// at cpp-tests.wasm.ImGui_ImplGlfw_Init(GLFWwindow*, bool, GlfwClientApi)
684+
#ifndef __EMSCRIPTEN__
677685
bd->MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
678686
bd->MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
679687
bd->MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
@@ -689,6 +697,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
689697
bd->MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
690698
bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
691699
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
700+
#endif
692701
#endif
693702
glfwSetErrorCallback(prev_error_callback);
694703
#if GLFW_HAS_GETERROR && !defined(__EMSCRIPTEN__) // Eat errors (see #5908)
@@ -1098,7 +1107,7 @@ struct ImGui_ImplGlfw_ViewportData
10981107
WNDPROC PrevWndProc;
10991108
#endif
11001109

1101-
ImGui_ImplGlfw_ViewportData() { memset(this, 0, sizeof(*this)); IgnoreWindowSizeEventFrame = IgnoreWindowPosEventFrame = -1; }
1110+
ImGui_ImplGlfw_ViewportData() { memset((void*)this, 0, sizeof(*this)); IgnoreWindowSizeEventFrame = IgnoreWindowPosEventFrame = -1; }
11021111
~ImGui_ImplGlfw_ViewportData() { IM_ASSERT(Window == nullptr); }
11031112
};
11041113

0 commit comments

Comments
 (0)