-
Notifications
You must be signed in to change notification settings - Fork 109
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
OpenGL renderer glitches on window scale (MacOS, retina) #109
Comments
Have just verified same issue with latest (master) version of code |
I wish I had a Mac to test on; I can't get the same results on Windows or Linux messing with display scaling. Does it also do that on the included examples? |
I am also affected by this plague, is there any workarounds? |
Oh no, I thought this was fixed. Are you using the crate or the github version? I don't have a Mac to test on, but I'll see what I can do. |
I am following the rogue like tutorial and i am using the following version of rltk:
Example code having this issue: |
Just checking in to see if there's any progress on this? I've got the same issue, but I'm glad that it only seems to affect MacOS. |
I tried debugging it, but didn't get very far, as my Rust is very basic. |
Just getting back into the swing of things after being unwell and then having to care for my mother being unwell. It does look like a DPI issue, I have a few ideas - I'll do some digging and post results. Trying to avoid having to buy a Mac to test with! |
Happy to help to diagnose it, I run into it each time. I also cannot build bracket-lib with Metal (#188). |
Now that's interesting. Updating glutin and winit has given me similar behavior on Windows! It looks like when Update: The fix worked with display scaling on Ubuntu X/11. Weird stuff happened on Ubuntu/Wayland - but it often does, so I'll worry about that as a separate issue. The code I'm testing is with the latest head (to update dependencies; do a clean first). Then in fn on_resize(
bterm: &mut BTerm,
physical_size: glutin::dpi::PhysicalSize<u32>,
dpi_scale_factor: f64,
send_event: bool,
) -> Result<()> {
INPUT.lock().set_scale_factor(dpi_scale_factor);
let mut be = BACKEND.lock();
if send_event {
bterm.resize_pixels(
physical_size.width as u32,
physical_size.height as u32,
be.resize_scaling,
);
}
let gl = be.gl.as_ref().unwrap();
unsafe {
gl_error_wrap!(
gl,
gl.viewport(
0,
0,
physical_size.width as i32,
physical_size.height as i32,
)
);
} |
I just committed the code that gives sensible behavior on Windows and Ubuntu/X11. Would someone mind giving this a go on a Mac for me, please? |
That's progress. :-) I suspect I can find a couple of other uses of DPI that are causing that issue. I'll go digging in a minute. (The bouncy gif is trippy!) |
Found the downside of the above fix - it messes up mouse position calculation after the window is resized. I think I know how to get this fixed, though - it may be tomorrow, I'm running short of time for the day. Thanks for the help - I'm pretty sure I've narrowed it down. |
#109 Scaling handler. * Phase 1 - mouse position is a simple extent based calculation. Test commit to move to my other test machines. * Display scaling isn't supported yet, and there's some cleaning to do - but this is scaling perfectly on X11/Ubuntu and Windows for me with different display scaling settings. * Format run * This should fix scaling. * Cleanup commented code.
Ok, I've taken the changes that helped earlier and gone a little further with them - and completely rewritten the mouse positioning section. This should help with the scaling issues. On my Ubuntu/X11 and Windows installations it's dead on the money both initially and after a resize on various scaling settings (tested 125%, 150%, 200%). So I'm really hopeful that this will help with the OS X issues. |
Thank you very much! |
…rather than trusting the event parameter. Getting some slightly odd results in testing when I trust the event.
…ow works on my test Wayland install.
…ow works on my test Wayland install. Now also includes DPI changes.
Progress! I found someone else who had suffered a similar problem, and applied their fix. Turned out to be two lines of code! It now scales correctly on everything I have available to test with - Windows, Ubuntu 20.1/X11, Ubuntu 20.1/Wayland. That's the first time Wayland has look right in a few |
A friend (Red blob games on the roguelikedev discord) informs me that it is working really well on his Mac now. :-) |
I've now had two people tell me that this is working correctly now. So I'm closing this issue - please re-open if the plague returns! |
If I try to run simple example (using default OpenGL renderer) and try to resize game window, it acts weird. With original size render area take 100% of the window. If I shrink window vertically, render area shrinks non in proportion, leaving some of the window blank. On the other hand, if I resize window to be larger, drawing area doesn't fit into window. Same happens to horizontal scaling.
I think is caused by retina display on my laptop, as I've seen other issues in tracker related to hdpi display.
Here's an example of drawing 80x50 red area and resizing a window:
Source code for example:
The text was updated successfully, but these errors were encountered: