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

Weird *1.5 scale on rendered images #289

Open
m4ntis opened this issue Jan 18, 2021 · 3 comments
Open

Weird *1.5 scale on rendered images #289

m4ntis opened this issue Jan 18, 2021 · 3 comments

Comments

@m4ntis
Copy link

m4ntis commented Jan 18, 2021

Hi there,

I'm using the latest version of piston_window (0.117.0) on linux (updated arch), and I'm having this weird issue where images I render using the code below are all *1.5 zoomed. I can get it to kinda work with something hacky along the lines of c.transform.zoom(0.667) but it's weird + the scaling isn't perfect and I get bad aliasing.

use piston_window::*;
use std::path::Path;

fn main() {
    let mut window: PistonWindow = WindowSettings::new("foo", (640, 480))
        .exit_on_esc(true)
        .build()
        .unwrap();

    let mut ctx = window.create_texture_context();
    let mask = Texture::from_path(
        &mut ctx,
        Path::new("assets/foo.png"),
        Flip::None,
        &TextureSettings::new(),
    )
    .unwrap();

    while let Some(e) = window.next() {
        match e {
            Event::Loop(Loop::Render(_)) => {
                window.draw_2d(&e, |c, g, d| {
                    clear(color::hex("4d4d4d"), g);
                    image(&mask, c.transform, g);
                    ctx.encoder.flush(d);
                });
            }
            _ => {}
        }
    }
}
@m4ntis
Copy link
Author

m4ntis commented Jan 18, 2021

So I found a temporary fix that avoids the aliasing, c.transform.zoom(2.0 / 3.0) instead of c.transform.zoom(0.667). Still, weird solution I'd love to avoid + idk what runtime performance issues may arise from scaling each loaded asset

@m4ntis
Copy link
Author

m4ntis commented Jan 23, 2021

This does not seem to happen with the Sdl2Window backend.

@bvssvni
Copy link
Member

bvssvni commented Jan 24, 2021

Do you have a retina screen?

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

No branches or pull requests

2 participants