Skip to content

Commit

Permalink
use a fixed number of frames
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSentry committed Sep 5, 2023
1 parent 4d856d5 commit a9b8fb1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/window/window_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
//! the mouse pointer in various ways.
use bevy::{
core::FrameCount,
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
window::{CursorGrabMode, PresentMode, PrimaryWindow, WindowLevel, WindowTheme},
window::{CursorGrabMode, PresentMode, WindowLevel, WindowTheme},
};

fn main() {
Expand Down Expand Up @@ -51,14 +52,13 @@ fn main() {
.run();
}

fn toggle_visible(mut primary_window: Query<&mut Window, With<PrimaryWindow>>, time: Res<Time>) {
let mut window = primary_window.single_mut();
fn toggle_visible(mut window: Query<&mut Window>, frames: Res<FrameCount>) {
// The delay may be different for your app or system.
if !window.visible && time.elapsed_seconds() >= 1.0 {
if frames.0 == 3 {
// At this point the gpu is ready to show the app so we can make the window visible.
// Alternatively, you could toggle the visibility in Startup.
// It will work, but it will have one white frame before it starts rendering
window.visible = true;
window.single_mut().visible = true;
}
}

Expand Down

0 comments on commit a9b8fb1

Please sign in to comment.