support HiDPI in picking example#72
Closed
dbacchet wants to merge 1 commit intomosra:masterfrom
dbacchet:dpi-aware-picking
Closed
support HiDPI in picking example#72dbacchet wants to merge 1 commit intomosra:masterfrom dbacchet:dpi-aware-picking
dbacchet wants to merge 1 commit intomosra:masterfrom
dbacchet:dpi-aware-picking
Conversation
dbacchet
commented
Dec 9, 2019
| .setViewport(GL::defaultFramebuffer.viewport().size()); | ||
|
|
||
| /* dpi normalization to properly convert windows to framebuffer pixels while picking */ | ||
| #ifdef MAGNUM_TARGET_GL |
Contributor
Author
There was a problem hiding this comment.
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
Contributor
Author
|
tested on macOS 10.14 on a MacBook Pro with Retina display (where the ratio is 2 by default) and also setting custom |
Owner
|
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! 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.