-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Fixed it so that the drawing when hidpi is correct (OSX) #212
Fixed it so that the drawing when hidpi is correct (OSX) #212
Conversation
Thank you for the PR! Proper high DPI support is something I'd definitely like to add in the future (although I might make it optional, as I don't have access to a high DPI screen myself and don't want to force people to use something I can't test very well). I'm a little uneasy about the workaround for resizes, however - I'd rather solve the issue properly to avoid creating more issues down the line. Questions:
WindowEvent::SizeChanged(width, height) => {
ctx.window.window_width = width;
ctx.window.window_height = height;
let (pixel_width, pixel_height) = ctx.window.sdl_window.drawable_size();
graphics::update_window_projection(
ctx,
pixel_width as i32,
pixel_height as i32,
);
state.event(ctx, Event::Resized { width, height })?;
} |
Thanks for the detailed advice. Answers: With the fix you presented, it was drawn correctly. In Screenshot 1 as well, |
I noticed the anomaly in And even if you multiply that anomalous value by something like dpi scale, it won't be able to deal with the situation both before and after the window resizes. |
That's very weird 🤔 The |
In Screenshot 2, after the window resizes, the drawing area is correct, but the texture being drawn is 1/4 the size. Screenshot 1 also has this problem, If this is the case, it can be cured by moving the window. Earlier I had misidentified the problem because I hadn't noticed it. So it's not that there is something wrong with |
Ah, I think I understand why all of this is happening now 😄
So I think the solution to get rendering to look the same in both high DPI and low DPI mode would be to always match the startup behaviour - i.e. set the projection matrix to the window size, and the viewport to the drawable size, effectively scaling everything to match the target DPI. I like this approach, as it should mean that existing code will 'just work' in high DPI mode. I've been looking at Love2D's code while we've been discussing this, and I think this is the approach they take as well: I will create a branch with these changes applied - hopefully then you can test them with your code 🙂 |
I have pushed a branch called |
Wonderful! |
Excellent! I've merged Thank you so much for your help in figuring out the right way forward with this 😄 |
With this PR, rendering in HiDPI mode on MacOS is rendered correctly in high definition and pixels blur-free.
I briefly tested this fix in Windows as well, and there seemed to be no problem.