ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
58.87k stars 10.05k forks source link

HiDPI with Emscripten and GLFW #7519

Open mikamyara opened 3 months ago

mikamyara commented 3 months ago

Version/Branch of Dear ImGui:

Version 1.90.5

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

emscripten 3.1.57

Full config/build information:

No response

Details:

I searched a lot but I did not find something satisfactory to work with HiDPI in the contexte of ImGUI/emscripten/GLFW. I rewrote a part of my code to insert a scaling factor, for example by 2, then create a glfw window twice the size, as well as for the viewport. I rescaled fonts as well as the addRect/addline/addEverything I used in custom widgets. Then I display all and I get a really better quality. Unfortunately : the mouse now does not work, I guess it behaves as if the image was not downscaled by a factor 2. What should be the good practice in this context ? Best Regards, Mike

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

jpcerrone commented 1 month ago

I was having a similar problem and solved it by following these steps:


- Removing `image-rendering: pixelated;` from the shell_minimal.html file fixed the bluriness when using windows DPI settings above 100%.
- I think you could use another js function that gets the actual DPI settings, with `window.devicePixelRatio` if you wanted to scale your widgets accordingly. With the steps I wrote here I get the same look and sizes at 100% and 125% DPI's. But they don't look blurry.