mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-05-06 06:14:29 +00:00
handle 0x0 windows, fixes minimizing on windows
This commit is contained in:
parent
807b095b15
commit
348cb3045b
19
src/lib.rs
19
src/lib.rs
|
@ -398,15 +398,18 @@ pub fn init() -> GameResult {
|
|||
}
|
||||
*flow = ControlFlow::Exit;
|
||||
}
|
||||
WindowEvent::Resized(_) => {
|
||||
if let (Some(ctx), Some(game)) = (&mut context, &mut game) {
|
||||
let state_ref = unsafe { &mut *game.state.get() };
|
||||
WindowEvent::Resized(size) => {
|
||||
// Minimizing a window on Windows causes this event to get called with a 0x0 size
|
||||
if size.width != 0 && size.height != 0 {
|
||||
if let (Some(ctx), Some(game)) = (&mut context, &mut game) {
|
||||
let state_ref = unsafe { &mut *game.state.get() };
|
||||
|
||||
state_ref.tmp_canvas = Canvas::with_window_size(ctx).unwrap();
|
||||
state_ref.game_canvas = Canvas::with_window_size(ctx).unwrap();
|
||||
state_ref.lightmap_canvas = Canvas::with_window_size(ctx).unwrap();
|
||||
state_ref.handle_resize(ctx).unwrap();
|
||||
graphics::window(ctx).update_gfx(&mut game.ui.main_color, &mut game.ui.main_depth);
|
||||
state_ref.tmp_canvas = Canvas::with_window_size(ctx).unwrap();
|
||||
state_ref.game_canvas = Canvas::with_window_size(ctx).unwrap();
|
||||
state_ref.lightmap_canvas = Canvas::with_window_size(ctx).unwrap();
|
||||
state_ref.handle_resize(ctx).unwrap();
|
||||
graphics::window(ctx).update_gfx(&mut game.ui.main_color, &mut game.ui.main_depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
WindowEvent::Touch(touch) => {
|
||||
|
|
Loading…
Reference in a new issue