mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-10 19:03:30 +00:00
example_emscripten_wgpu is throwing an error in InitWGPU function #6640
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#6640
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I am building the emscripten example on windows. The console in the browser throws an error saying
I am able to fix this by changing the line in the
InitWGPUfunction to use the function mentioned in the error like thisbecomes
After this I am able to see the ui in the browser.
Additionally, I was unable to compile the example in windows unless I removed this line from the MakeFile
I am unsure if I am fixing something correctly here or just using it in a way that is not the intended way to use it.
I'm experiencing the same error and waiting for the answer.
By the way, I can compile successfully under Windows 10 with the latest emscripten, with or without code modifications. It's just that the browser reports the above error if I don't modify the code.
Thanks, changing this line helped! But now I get very low-resolution version. Any clues why?
It's not a bug, it's just set up that way on purpose.
You can prevent stretching by modifying
index.html:@Traveller23 Thanks, I removed those two lines and now it renders with the same resolution just not in fullscreen:

Where would I know about these settings?
Your screenshot shows that your viewport's size is 1280x720, but the actual size of the light blue part of the screenshot is 1600x900, so I'm guessing you're using your browser's zoom. You should leave the browser's zoom level at 100%.
This 1280x720 is defined in main.cpp, you can find it by searching for "glfwCreateWindow". There should not be any scaling of ImGui's screen output.
Thanks a lot, there was zoom indeed!
I've tried to change
glfwCreateWindowconstants or use this solution https://stackoverflow.com/questions/53752243/how-to-retrieve-in-browser-size-of-emscripten-canvasBut with no effect on window actual size.
Looks like there is some problem with updating wasm after recompilation, since server doesn't change GUI despite of any changes I make in main.cpp.
So, looks like my browser caches wasm modules somehow. So it updates only when I open it in incognito mode (they differ in window size and number of bangs):

How can I control this setting?
Still, I don't understand, how can I get actual browser screen size to fit window in
glfwCreateWindow.With
emscripten_get_canvas_element_size("#canvas", &width, &height);I get 300x150 pixels (same as here).With
emscripten_get_screen_size(&width, &height);I get full monitor resolution 1920x1080 but not browser window.Solved it by changing back in html-file
And the following code:
@sairus7 Your question is way off-topic, and this will have an impact on the handling of this issue.
For questions not related to ImGui itself, I suggest you ask on stackoverflow.
Question is off topic, but that said, if there’s an issue with our example not scaling properly on some setup it should be fixed in the example (html or c++ side). @Traveller23 do you have an opinion on the right way to fix this issue?
As mentioned above, just delete the two lines in
index.html.The auto-generated
index.htmldoesn't force ImGui's canvas to be stretched, so it shouldn't be stretched here either.In order to maintain the simplicity of the example, and the uniformity of all the examples, I don't recommend a more advanced way of getting the size of the canvas in C++.
Merged fix
981abb46.@Traveller23 If I remove the 100% specifiers in https://github.com/ocornut/imgui/blob/master/examples/libs/emscripten/shell_minimal.html then the examples canvas doesn't fill available space which is really undesirable IHMO. I would like our example to use as much space is available and update resolution accordingly, so it looks closer to a fullscreen application, rather than being in a "small" canvas like Emscripten default html template or a fixed resolution.
So when the browser window is resized from SDL/GLFW point of view it should be equivalent to a native Windows being resized and we use all that space.
@ocornut I see what you're trying to do, so a little more advanced and complex method is inevitable. In addition to the need to get the size of the canvas at initialization time, you also need to resize canvas as well as framebuffer when the window size changes.
I'll submit a pull request soon.
Thanks!
Interesting it did seem to work already on some setups but not all (maybe was browser specific, I forgot). Something that works everywhere would be great.
Submitted: https://github.com/ocornut/imgui/pull/6751
By the way, the latest code (commit
200053771a) still outputs jagged text on my machine. (Windows 10 + chrome 116) .I am sorry I don't know what you are referring to here by jagged text? Is your framebuffer missized on current master?
It doesn't for me. But if you are telling me that your PR fixes it that's good.
I apologize for my lack of description.
What I mean is that until I apply my pull request, I get the same output as before:
Because you said that after applying this (
ocornut/imgui@981abb4612) update, some machines no longer have the jaggedness problem, so I reported my situation.Thanks! Moved this to #6751, i know understand that SDL does a similar thing as you did, and GLFW doesn't, and this is why our current Makefile for the GLFW side use a different template as the one used by SDL example makefile.