Open mrmav opened 9 months ago
You were right: you should not add your GLFW source when you compile your project with emscripten as it uses its own implementation.
Your problem at the end is that GLFW's gamepad handling implementation has not been completed yet for emscripten that's why your compiler can't find the glfwUpdateGamepadMappings
and glfwGetGamepadState
functions. If you don't call these functions then there shouldn't be a problem when compiling.
To get gamepad input, I used the HTML5 bindings without problems. However this may have limitations too as it is the only polling-based API while the others are event-based as it is stated at the top of the page.
By the way, earlier this problem prevented using ImGui with GLFW + Emscripten but the ImGui teams also realized that the problem is not their fault, if you check the commit (at the bottom of the linked issue) then you can see they just started to use the __EMSCRIPTEN__
macro to ignore the aforementioned functions.
So if you want to use GLFW's gamepad handling then you have to wait for the complete implementation (or start contributing to it yourself). Until then use the HTML5 API.
If anyone would like to add glfwUpdateGamepadMappings
and glfwGetGamepadState
to emscripten's GLFW implementation that would be great! Marking this bug a help wanted.
You were right: you should not add your GLFW source when you compile your project with emscripten as it uses its own implementation.
Your problem at the end is that GLFW's gamepad handling implementation has not been completed yet for emscripten that's why your compiler can't find the
glfwUpdateGamepadMappings
andglfwGetGamepadState
functions. If you don't call these functions then there shouldn't be a problem when compiling.To get gamepad input, I used the HTML5 bindings without problems. However this may have limitations too as it is the only polling-based API while the others are event-based as it is stated at the top of the page.
By the way, earlier this problem prevented using ImGui with GLFW + Emscripten but the ImGui teams also realized that the problem is not their fault, if you check the commit (at the bottom of the linked issue) then you can see they just started to use the
__EMSCRIPTEN__
macro to ignore the aforementioned functions.So if you want to use GLFW's gamepad handling then you have to wait for the complete implementation (or start contributing to it yourself). Until then use the HTML5 API.
Thank you for this response! It was very insightful in many ways. I'll take a look and add the guard as you mentioned and try it when I get the time. Will also take a look if for web builds I can manage using the HTML5 bindings.
I'll close this issue when I get the chance of testing this.
我在编译使用glfw库的c项目时,也遇到了找不到X11的错误,是emscripten 不能编译引用glfw的程序吗? 希望你能给到帮助,谢谢
I need help understanding how I would use emscripten with glfw. My first initial problem was the cmake configure command complain about this:
After hours trying to fix this issue, I found someone stating that when building with emscripten, one doesn't need to add the glfw library? So I added a guard to my cmakelists:
I still linked like so:
target_link_libraries(${PROJECT_NAME} glfw ${GLFW_LIBRARIES} imgui)
I also added the following:Now I'm getting linking errors, stating that glfw symbols are not found. Can anybody point me in the right direction on how to use emscripten and glfw? Thank you!
Version of emscripten/emsdk:
Failing command line in full:
Full link command and output with
-v
appended: