# Determine DPI?

**URL:** <https://discourse.glfw.org/t/determine-dpi/571>\
**Category:** support\
**Created:** [June 2, 2013, 3:55pm UTC](https://discourse.glfw.org/t/determine-dpi/571 "2013-06-02T15:55:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 2, 2013, 3:55pm UTC](https://discourse.glfw.org/t/determine-dpi/571/1 "2013-06-02T15:55:03Z")

</div>

**[kgamiel](https://sourceforge.net/u/kgamiel/)** wrote on [Sunday, June 02, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/b4903d44/#9a8a):

In a cross-platform glfw application, what is the preferred way to determine dpi of current display? Specifically on OSX and Linux.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 3, 2013, 10:07am UTC](https://discourse.glfw.org/t/determine-dpi/571/2 "2013-06-03T10:07:23Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Monday, June 03, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/b4903d44/#5dbb):

Not with 2.7, but you can with 3.0.

---

<div class="post-metadata">

**Author:** ![Asger\_Hoedt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/asger_hoedt/32/170_2.png) [@Asger\_Hoedt](https://discourse.glfw.org/u/Asger_Hoedt)\
**Post date:** [February 8, 2018, 7:15am UTC](https://discourse.glfw.org/t/determine-dpi/571/3 "2018-02-08T07:15:57Z")

</div>

Can you elaborate on how? I’ve seen the changes for GLFW 3.0 mentions high DPI and I’ve found glfwSetFramebufferSizeCallback, but I have no idea how to initialize a window in GLFW that uses windows DPI or how to specify the window and framebuffer size myself. The result is that I have a very tiny GLFW window on my laptop monitor and have to squint to see use my GUI 😉

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [February 8, 2018, 10:06am UTC](https://discourse.glfw.org/t/determine-dpi/571/4 "2018-02-08T10:06:22Z")

</div>

Window creation sets the size of the window in screen coordinates, once you’ve done this you can then [query the framebuffer size with glfwGetFramebufferSize](http://www.glfw.org/docs/latest/group__window.html#ga0e2637a4161afb283f5300c7f94785c9) and use the ratio between screen size and framebuffer size to scale your UI.

---

<div class="post-metadata">

**Author:** ![Asger\_Hoedt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/asger_hoedt/32/170_2.png) [@Asger\_Hoedt](https://discourse.glfw.org/u/Asger_Hoedt)\
**Post date:** [February 8, 2018, 7:30pm UTC](https://discourse.glfw.org/t/determine-dpi/571/5 "2018-02-08T19:30:06Z")

</div>

Well in my case windows scaling is set to 250% (verified with GetDpiForWindow(hwnd)) but my window and framebuffer have the same size, so it looks like glfw ignores the dpi.

I’m on 3.2.1 and using an intel GPU btw. Haven’t tried if using my nvidia GPU changes anything, but I’m assuming it’s handled by windows and GPU/driver independent.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [February 9, 2018, 10:05am UTC](https://discourse.glfw.org/t/determine-dpi/571/6 "2018-02-09T10:05:24Z")

</div>

Ignore my answer above, I misunderstood the question - I thought you had framebuffer size vs window size issues.

[You can query the DPI through the glfwGetMonitorPhysicalSize function](http://www.glfw.org/docs/latest/monitor_guide.html#monitor_size) along with the math listed there.

---

<div class="post-metadata">

**Author:** ![Asger\_Hoedt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/asger_hoedt/32/170_2.png) [@Asger\_Hoedt](https://discourse.glfw.org/u/Asger_Hoedt)\
**Post date:** [February 9, 2018, 10:45am UTC](https://discourse.glfw.org/t/determine-dpi/571/7 "2018-02-09T10:45:23Z")

</div>

No I would actually love to have that issue, because that would mean progress. 😃

I’m not sure how calculating the DPI helps me. I already know the DPI from windows own API (but using glfw of course makes it slightly easier.)

My problem is that my system has a scaling mode of 250%. When I call glfwCreateWindow with width and height 640x480 I would expect a window with size 1600x1200 and a framebuffer size of 640x480. What I get is a window and framebuffer size of 640x480 and no way (that I’ve found) to change. So how do I get GLFW to respect windows scaling mode?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [February 9, 2018, 11:36am UTC](https://discourse.glfw.org/t/determine-dpi/571/8 "2018-02-09T11:36:54Z")

</div>

The [window size you request is in screen coordinates](http://www.glfw.org/docs/latest/intro_guide.html#coordinate_systems). So if you want a window size of 1600x1200 screen coordinates you ask for one of that size.

The OS pixel ratio of framebuffer to screen coordinates and DPI are two separate things. In your case you have 1:1 pixels to screen coords (I think this is always the case for Windows OS but I’m not sure).

So you need to alter your application code to handle this. Once you’ve calculated the DPI you then need to scale your window size and UI size to suit. If you want to render to a lower resolution then scale up you’ll need to use a render target and then scale, but scaling the UI would give better quality.
