-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[emscripten + glfw]: Added support for GLFW3 contrib port #7647
base: master
Are you sure you want to change the base?
Conversation
- implements GFLW 3.4.0 features + bug fixes (like full gamepad support)
- fixes "Emscripten build runtime error: Unable to preventDefault inside passive event listener"
Thank you for updating this.
I'll read the rest when I have some time. |
I agree it is a bit confusing. I renamed it per your suggestion. |
|
You asked me to fix the #7600 issue for the embedded path and the fix is to call
Ok I will change it. |
Thanks! I didn't realize this was the fix for #7600. I'll try to test this now. |
I wonder if we should:
What is the Would it make some sense to ask both window and canvas names in |
I made the change you requested I made it as a ![]() At least with the
In regards to your last questions:
I don't think I have an opinion one way or another. I don't envision the port to ever require something that would need to be added in But it doesn't cost much to do it the way you suggest and I am fine with it if that is the direction you want to go with.
The documentation explains in detail the parameters provided to this function which can handle 3 different use cases. The "normal" use case for ImGui is to use the full window, and this corresponds to the css selector "window". As you can see in my WIP videos on a new project I am working on, (WIP1 and WIP2), in this instance I DON'T use "window" but the canvas selector itself, thus having ImGui run in a resizable frame in the browser.
I think the issue is that, as I mentioned, with the new API you don't necessarily use the full window, so I am not sure how the user could do that. And how would you pass the 3rd parameter (which is the handle to resize the canvas when you want one)? |
- added ImGui_ImplGlfw_InstallEmscriptenCallbacks and deprecated ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback
After spending more time thinking about your proposed changes (add It makes it easier for regular ImGui user. Although I was worried about the fact that the // main.cpp
#ifdef __EMSCRIPTEN__
#include <GLFW/emscripten_glfw3.h>
#endif
// ....
#ifdef __EMSCRIPTEN__
ImGui_ImplGlfw_InstallEmscriptenCallbacks(window, "#canvas"); // this will make it full window
emscripten_glfw_make_canvas_resizable(window, "#xxx", "#yyy"); // this will make it resizable via #xxx and handle #yyy
#endif In other words, my code supports calling In conclusion, I would go for this solution which covers 99.9% of the use cases while still allowing to use the more advanced usage. It is less discoverable, but I am planning to write examples demonstrating it (including open sourcing the project I linked to in my previous message). I marked
|
Hi @ocornut, I just found out an issue which is reproducible in BOTH the old/embedded path as well as the new one on macOS
"V" is still pressed I am going to investigate of why this is happening and I will let you know what I find. |
As I pointed out in my comment:
Since this problem existed before I don't see a reason why this should prevent this PR to be merged (unless there are other reasons to prevent the merge of course). |
This is the PR implementing the changes as discussed in PR #7520. Due to the changes + merge conflicts, I decided to start clean and do a brand new PR.
As discussed, this PR adds support for the GLFW3 contrib port, but does NOT force the user to switch to it.
Makefile.emscripten
inexample_glfw_wgpu
andexample_glfw_opengl3
and as a result, building using these Makefiles, will build the same code as beforeCMakeLists.txt
forexample_glfw_wgpu
to automatically detect the version of emscripten used and if it can use the new port, it uses it: this gives an example on how to build with the new portThe most notable changes visible when using the GLFW3 contrib port are (which can be tested with the live demos)
Live demos:
-sUSE_GLFW=3
: demo--use-port=contrib.glfw3
: demo