-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added transparency to window builder (#3105)
Applogies, had to recreate this pr because of branching issue. Old PR: #3033 # Objective Fixes #3032 Allowing a user to create a transparent window ## Solution I've allowed the transparent bool to be passed to the winit window builder
- Loading branch information
Showing
5 changed files
with
47 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// An example of how to display a window in transparent mode | ||
/// [Documentation & Platform support.](https://docs.rs/bevy/latest/bevy/prelude/struct.WindowDescriptor.html#structfield.transparent) | ||
use bevy::{prelude::*, render::pass::ClearColor, window::WindowDescriptor}; | ||
|
||
fn main() { | ||
App::new() | ||
// ClearColor must have 0 alpha, otherwise some color will bleed through | ||
.insert_resource(ClearColor(Color::NONE)) | ||
.insert_resource(WindowDescriptor { | ||
// Setting `transparent` allows the `ClearColor`'s alpha value to take effect | ||
transparent: true, | ||
// Disabling window decorations to make it feel more like a widget than a window | ||
decorations: false, | ||
..Default::default() | ||
}) | ||
.add_startup_system(setup) | ||
.add_plugins(DefaultPlugins) | ||
.run(); | ||
} | ||
|
||
fn setup( | ||
mut commands: Commands, | ||
asset_server: Res<AssetServer>, | ||
mut materials: ResMut<Assets<ColorMaterial>>, | ||
) { | ||
let texture_handle = asset_server.load("branding/icon.png"); | ||
commands.spawn_bundle(OrthographicCameraBundle::new_2d()); | ||
commands.spawn_bundle(SpriteBundle { | ||
material: materials.add(texture_handle.into()), | ||
..Default::default() | ||
}); | ||
} |