piston icon indicating copy to clipboard operation
piston copied to clipboard

Rendered window bigger than specified size

Open Ironmaggot opened this issue 7 years ago • 7 comments

When using WindowSettings::new() to create a window, the displayed window size is bigger than the size entered into the WindowSettings::new() size argument.

In other words. My monitor resolution is 1920x1080. Creating a window with the same size will result in a window which is larger than my screen. For example, if I create a window the size of 900x900, then the displayed window does not fit on the screen with its height. Displayed 900x900 window is taller than my 1080 tall monitor.

Ironmaggot avatar Aug 28 '17 16:08 Ironmaggot

Which OS and window backend?

bvssvni avatar Aug 28 '17 20:08 bvssvni

Oh, yes, forgot to mention it. It's Win 10.

Ironmaggot avatar Aug 29 '17 08:08 Ironmaggot

About the backend I am not sure - its the default backend, I guess.

Here's the entirety of the code.

extern crate piston_window;

use piston_window::*;

fn main() {
    let mut window: PistonWindow =
        WindowSettings::new("Hello Piston!", [900, 900])
        .decorated(false).exit_on_esc(true).build().unwrap();
    while let Some(event) = window.next() {
        window.draw_2d(&event, |context, graphics| {
            clear([1.0; 4], graphics);
            rectangle([1.0, 0.0, 0.0, 1.0], // red
                      [400.0, 700.0, 100.0, 100.0],
                      context.transform,
                      graphics);
        });
    }
}

Ironmaggot avatar Aug 29 '17 16:08 Ironmaggot

Hi, was this solved I have the same issue on Linux image I measured it with the screen tool and is WAY bigger that specified, I noticed the same with other peoples Piston projects, the windows are bigger.

thanks

varomix avatar Dec 02 '18 03:12 varomix

I think the issue might be due to lack of HDPI support in the default backend. Try using the GLFW backend:

extern crate piston_window;
extern crate glfw_window;
use glfw_window::GlfwWindow;
use piston_window::*;

fn main() {
    let mut window: PistonWindow<GlfwWindow> =
        WindowSettings::new("Hello Piston!", [900, 900])
            .decorated(false).exit_on_esc(true).build().unwrap();
    while let Some(event) = window.next() {
        window.draw_2d(&event, |context, graphics| {
            clear([1.0; 4], graphics);
            rectangle([1.0, 0.0, 0.0, 1.0], // red
                      [400.0, 700.0, 100.0, 100.0],
                      context.transform,
                      graphics);
        });
    }
}

lwiklendt avatar Dec 03 '18 05:12 lwiklendt

I found out the issue is Glutin so I did change that GLFW and that works

thanks

varomix avatar Dec 03 '18 05:12 varomix

It's "cargo add pistoncore-glfw_window" for anyone coming to this party.

vwood avatar Mar 10 '20 12:03 vwood