Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support HiDPI in picking example #72

wants to merge 1 commit into from

support HiDPI in picking example #72

wants to merge 1 commit into from


Copy link

@dbacchet dbacchet commented Dec 9, 2019

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.

@@ -245,6 +247,12 @@ PickingExample::PickingExample(const Arguments& arguments): Platform::Applicatio
.setProjectionMatrix(Matrix4::perspectiveProjection(35.0_degf, 4.0f/3.0f, 0.001f, 100.0f))

/* dpi normalization to properly convert windows to framebuffer pixels while picking */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if using directly MAGNUM_TARGET_GL is ok or if there is a better way to check if framebufferSize() and windowSize() are available in the current platform

Copy link
Contributor Author

dbacchet commented Dec 9, 2019

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 mosra added this to the 2019.1c milestone Dec 12, 2019
@mosra mosra added this to TODO in Project management via automation Dec 12, 2019
Copy link

mosra commented Dec 12, 2019

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 815e7ed in a way similar to how it was done for the other example. Thanks a lot! 👍

@mosra mosra closed this Dec 12, 2019
Project management automation moved this from TODO to Done Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Successfully merging this pull request may close these issues.

None yet

2 participants