mosra / magnum-examples

Examples for the Magnum C++11 graphics engine
https://magnum.graphics/
The Unlicense
282 stars 95 forks source link

support HiDPI in picking example #72

Closed dbacchet closed 4 years ago

dbacchet commented 4 years ago

On machines where the window and the framebuffer have different sizes, the picking example did not work properly, because of the conversion between mouse coordinates and pixels in the framebuffer.

This PR introduces a normalization factor that is calculated as framebufferSize()/windowSize() and converts mouse coords using that scaling.

dbacchet commented 4 years ago

tested on macOS 10.14 on a MacBook Pro with Retina display (where the ratio is 2 by default) and also setting custom MAGNUM_DPI_SCALING values while launching the app

mosra commented 4 years ago

Ah, that's probably why the example behaved extra weird when I tried the web build on my HiDPI screen (where it's the same difference between framebuffer and window size). I did a similar change a while back for the Mouse Interaction example, not sure why not here tho.

Commited as 815e7eda681f132cd716a95bc1bf1caed07817ae in a way similar to how it was done for the other example. Thanks a lot! :+1: