GithubHelp home page GithubHelp logo

HighDPI issues on linux about tracy HOT 11 CLOSED

wolfpld avatar wolfpld commented on May 9, 2024
HighDPI issues on linux

from tracy.

Comments (11)

mgerhardy avatar mgerhardy commented on May 9, 2024

Screenshot from 2020-07-02 16-26-19

from tracy.

mgerhardy avatar mgerhardy commented on May 9, 2024

Screenshot from 2020-07-02 16-27-10

from tracy.

wolfpld avatar wolfpld commented on May 9, 2024

You can set an appropriate dpiScale in profiler/src/main.cpp. Ideally this should be retrieved from the system.

from tracy.

mgerhardy avatar mgerhardy commented on May 9, 2024

Shouldn't glfwGetMonitorContentScale help here cross platform? According to the docs it should:

Will give it a try and let you know.

from tracy.

mgerhardy avatar mgerhardy commented on May 9, 2024

Something like this - unfortunately I can't test this as I currently only have glfw 3.2 - I first to build a newer version.

diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp
index 2485ead7..73ddedc1 100644
--- a/profiler/src/main.cpp
+++ b/profiler/src/main.cpp
@@ -242,6 +242,14 @@ int main( int argc, char** argv )
     gl3wInit();
     glfwSetWindowRefreshCallback( window, WindowRefreshCallback );
 
+#if GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 3)
+    GLFWmonitor* monitor = glfwGetWindowMonitor(window);
+    if (monitor == nullptr) {
+        monitor = glfwGetPrimaryMonitor();
+    }
+    if (monitor != nullptr) {
+        float xscale, yscale;
+        glfwGetMonitorContentScale(monitor, &xscale, &yscale);
+        dpiScale = xscale > yscale ? xscale : yscale;
+    }
+#else
 #ifdef _WIN32
     typedef UINT(*GDFS)(void);
     GDFS getDpiForSystem = nullptr;
@@ -250,6 +258,7 @@ int main( int argc, char** argv )
         getDpiForSystem = (GDFS)GetProcAddress(dll, "GetDpiForSystem");
     if (getDpiForSystem)
         dpiScale = getDpiForSystem() / 96.f;
+#endif
 #endif
 
     // Setup ImGui binding

from tracy.

mgerhardy avatar mgerhardy commented on May 9, 2024

tested the above now - works quite nice now. Not sure which version of glfw you are targeting for. But if 3.3 is the min version - one can also remove the checks and the win32 code.

from tracy.

mgerhardy avatar mgerhardy commented on May 9, 2024

I suppose I have to add the glfwGetPrimaryMonitor call, because the window is not yet initialized properly at that point. I think it would be better to move the dpiScale assignment after the window init. Looks like creating the window is not enough here.

from tracy.

wolfpld avatar wolfpld commented on May 9, 2024

glfwGetWindowMonitor doesn't do what you think it does (see docs). You'd need to enumerate available monitors (glfwGetMonitors) to detect on which monitor the window will be displayed, taking into account the possibility that monitor configuration might have changed since last run, and the saved window coordinates could have been adjusted by the window manager (or not at all, placing the window out-of-view, who knows).

Then you have trouble with multiple monitors with different DPI settings, but this problem is already present right now (not on Windows, which scale the window-contents bitmap to match the target monitor DPI). Proper fix would be needed to be done on ImGui side, I believe @ocornut has it in the works.

from tracy.

mgerhardy avatar mgerhardy commented on May 9, 2024

But it should at least do the (almost) same as the win32 specific code, no? I know that it doesn't deal with the edge cases.

At least it fixes the problem for me in a way, that renders the profiler's ui readable.

from tracy.

mgerhardy avatar mgerhardy commented on May 9, 2024

Or maybe provide a way to override the dpi scale factor with an env var? at least as a workaround...

from tracy.

wolfpld avatar wolfpld commented on May 9, 2024

Implemented as proposed in 5abd4c8.

from tracy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.