1

I'd like to change the resolution of a PistonWindow after it has been created. This would allow a user to change the resolution of the window while playing the game.

WindowSettings has a set_size method, but it doesn't seem to be accessible after the PistonWindow type is created.

A simplified example:

extern crate piston_window;

use piston_window::*;

fn main() {
    let mut window: PistonWindow = WindowSettings::new("Game Title", [200, 200])
        .exit_on_esc(true)
        .build()
        .unwrap();

    // Do some logic here, and change resolution to 400 x 400.

    while let Some(e) = window.next() {
        window.draw_2d(&e, |c, g| {
            ellipse([1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 100.0, 100.0], c.transform, g)
        });
    }
}
Stargateur
  • 24,473
  • 8
  • 65
  • 91
phoenix
  • 7,988
  • 6
  • 39
  • 45

1 Answers1

1

As far as I know, you can't. At least not of an existing window.

However, you can store the WindowSettings and re-create your window based on it when the user changes the resolution.