Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! This shows how to spawn an invisible window and turn it visible once it's ready to display. | ||
//! This is useful when you want to avoid the white window that shows up before the GPU is ready to render the app. | ||
|
||
use bevy::prelude::*; | ||
use bevy_internal::window::PrimaryWindow; | ||
|
||
fn main() { | ||
App::new() | ||
.add_plugins(DefaultPlugins.set(WindowPlugin { | ||
primary_window: Some(Window { | ||
// This will spawn an invisible window | ||
visible: false, | ||
..default() | ||
}), | ||
..default() | ||
})) | ||
.add_systems(Startup, setup) | ||
.run(); | ||
} | ||
|
||
fn setup(mut primary_window: Query<&mut Window, With<PrimaryWindow>>) { | ||
// At this point the gpu is ready to show the app so we can make the window visible | ||
// There might still be a white frame when doing it in startup. | ||
// Alternatively, you could have a system that waits a few seconds before making the window visible. | ||
primary_window.single_mut().visible = true; | ||
} |