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

Window example doesnt render quite right when i move it from a hidpi screen to 1x, or vice versa #1068

Closed
agmcleod opened this issue Sep 26, 2018 · 3 comments

Comments

@agmcleod
Copy link

Tested on macos high sierra, dont have a hidpi windows setup to test i'm afraid.

When I run the example, it appears on my main screen (the laptop hidpi 2), and looks like:

image

When i drag it to the second monitor, which is a standard 24" 1080p. It gets zoomed in sorta.

image

Once i drag the window corner to resize it, it fixes itself. I tried updating the example to handle the hidpi change, but it hasnt improved.

match event {
    glutin::Event::WindowEvent { event, .. } => match event {
        glutin::WindowEvent::CloseRequested => running = false,
        glutin::WindowEvent::HiDpiFactorChanged(dpi_factor) => {
            let logical_size = gl_window.get_inner_size().unwrap();
            gl_window.resize(logical_size.to_physical(dpi_factor));
            println!("{:?} - {:?}", event, logical_size.to_physical(dpi_factor));
        },
        glutin::WindowEvent::Resized(logical_size) => {
            let dpi_factor = gl_window.get_hidpi_factor();
            gl_window.resize(logical_size.to_physical(dpi_factor));
            println!("{:?} - {:?}", event, logical_size.to_physical(dpi_factor));
        },
        _ => (),
    },
    _ => ()
}

In the terminal, this is the output i see:

HiDpiFactorChanged(2.0) - PhysicalSize { width: 2048.0, height: 1536.0 }
Resized(LogicalSize { width: 1024.0, height: 768.0 }) - PhysicalSize { width: 2048.0, height: 1536.0 }
HiDpiFactorChanged(1.0) - PhysicalSize { width: 1024.0, height: 768.0 }
Resized(LogicalSize { width: 1024.0, height: 768.0 }) - PhysicalSize { width: 1024.0, height: 768.0 }
@francesca64
Copy link
Member

IIRC the example rendering code doesn't handle resizes at all. The triangle verts are never transformed, so they'll be in the same place after resizing.

(HiDpiFactorChanged also wouldn't need to be handled separately like this, as any DPI change that results in a resize would be accompanied by Resized. The former event is still useful if you're explicitly/specifically interested in DPI changes, though.)

@agmcleod
Copy link
Author

@francesca64 When i resize the screen with my above code, the scene skews with the new size. So the triangle stretches, which is what i expect.

Though im not sure why the scene is offset upon moving it to the other monitor, and how to handle that.

@kchibisov
Copy link
Member

kchibisov commented Sep 3, 2022

Fixed in #1435.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants