I am writing app with use of GLFW as window manager and I try to understand how window size in screen coordinates translates to framebuffer size. On most screens screen coordinate = pixel, from what I know, but retina displays from what I heard have different proportion of screen coordinate to pixels. I tried to come up with method that would detect proportion of screen coordinate to pixel, and I came up with creating window with given size then obtaining framebuffer size of that window and calculating propotion between two sizes. I don’t have retina display or anything fancy like that, and I wasn’t able to force different proportion of screen coordinate to pixel on my Windows machine. So question for more experienced people in community. Will my method work on retina displays or any other screen where mapping of pixel to screen cooordinate is not 1:1? Additionally is it guaranteed that vertical and horizontal screen coordinate to pixel proportion is always the same?
The relevant documentation for this in GLFW is the Framebuffer size and you may also want to be aware of Window content scale.
I don’t have retina display or anything fancy like that, and I wasn’t able to force different proportion of screen coordinate to pixel on my Windows machine.
The Windows OS at the moment has a 1:1 relationship between pixels and window coordinates.
Will my method work on retina displays or any other screen where mapping of pixel to screen cooordinate is not 1:1?
It depends on what you are trying to do with your measurement. If you are trying to judge the size of the text to render then the window content scale is the relevant factor. If you’re trying to perform graphics computations then the framebuffer size alone is sufficient. If you want to transform window coordinates to framebuffer coordinates then this is where the ratio is useful, and your method should work if you have the math right.
Additionally is it guaranteed that vertical and horizontal screen coordinate to pixel proportion is always the same?
In practice, yes, but I would not say that it is guaranteed. I would transform window coordinates to framebuffer coordinates using both the x and y scales.
These two answer my quastions, thank you.