Merge e37a5bcfc7 into f964ee1e3a
This commit is contained in:
commit
35e2518b3c
@ -19,6 +19,7 @@ extern crate alloc;
|
|||||||
|
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
|
||||||
|
use bevy_ecs::system::Commands;
|
||||||
use bevy_platform::sync::Mutex;
|
use bevy_platform::sync::Mutex;
|
||||||
|
|
||||||
mod event;
|
mod event;
|
||||||
@ -56,8 +57,7 @@ use bevy_app::prelude::*;
|
|||||||
impl Default for WindowPlugin {
|
impl Default for WindowPlugin {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
WindowPlugin {
|
WindowPlugin {
|
||||||
primary_window: Some(Window::default()),
|
spawn_primary_window: true,
|
||||||
primary_cursor_options: Some(CursorOptions::default()),
|
|
||||||
exit_condition: ExitCondition::OnAllClosed,
|
exit_condition: ExitCondition::OnAllClosed,
|
||||||
close_when_requested: true,
|
close_when_requested: true,
|
||||||
}
|
}
|
||||||
@ -66,23 +66,28 @@ impl Default for WindowPlugin {
|
|||||||
|
|
||||||
/// A [`Plugin`] that defines an interface for windowing support in Bevy.
|
/// A [`Plugin`] that defines an interface for windowing support in Bevy.
|
||||||
pub struct WindowPlugin {
|
pub struct WindowPlugin {
|
||||||
/// Settings for the primary window.
|
/// Whether or not to spawn a [`PrimaryWindow`] and its associated required components.
|
||||||
|
/// If you want to customize the primary window when it spawns, you can use an observer:
|
||||||
///
|
///
|
||||||
/// `Some(custom_window)` will spawn an entity with `custom_window` and [`PrimaryWindow`] as components.
|
/// ```
|
||||||
/// `None` will not spawn a primary window.
|
/// # use bevy_window::{CursorOptions, PresentMode, PrimaryWindow, Window, PresentMode};
|
||||||
|
/// # use bevy_ecs::prelude::*;
|
||||||
|
/// fn configure_window(
|
||||||
|
/// trigger: On<Add, PrimaryWindow>,
|
||||||
|
/// mut window: Query<(&mut CursorOptions, &mut PresentMode)>,
|
||||||
|
/// ) {
|
||||||
|
/// // This unwrap is guaranteed to succeed because the queried components are required on any [`Window`]
|
||||||
|
/// let (mut cursor_options, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||||
|
/// cursor_options.visible = false;
|
||||||
|
/// present_mode = PresentMode::AutoNoVsync;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// Defaults to `Some(Window::default())`.
|
/// Defaults to `true`.
|
||||||
///
|
///
|
||||||
/// Note that if there are no windows the App will exit (by default) due to
|
/// Note that if there are no windows the App will exit (by default) due to
|
||||||
/// [`exit_on_all_closed`].
|
/// [`exit_on_all_closed`].
|
||||||
pub primary_window: Option<Window>,
|
pub spawn_primary_window: bool,
|
||||||
|
|
||||||
/// Settings for the cursor on the primary window.
|
|
||||||
///
|
|
||||||
/// Defaults to `Some(CursorOptions::default())`.
|
|
||||||
///
|
|
||||||
/// Has no effect if [`WindowPlugin::primary_window`] is `None`.
|
|
||||||
pub primary_cursor_options: Option<CursorOptions>,
|
|
||||||
|
|
||||||
/// Whether to exit the app when there are no open windows.
|
/// Whether to exit the app when there are no open windows.
|
||||||
///
|
///
|
||||||
@ -129,15 +134,10 @@ impl Plugin for WindowPlugin {
|
|||||||
.add_event::<WindowThemeChanged>()
|
.add_event::<WindowThemeChanged>()
|
||||||
.add_event::<AppLifecycle>();
|
.add_event::<AppLifecycle>();
|
||||||
|
|
||||||
if let Some(primary_window) = &self.primary_window {
|
if self.spawn_primary_window {
|
||||||
let mut entity_commands = app.world_mut().spawn(primary_window.clone());
|
app.add_systems(PreStartup, |mut commands: Commands| {
|
||||||
entity_commands.insert((
|
commands.spawn(PrimaryWindow);
|
||||||
PrimaryWindow,
|
});
|
||||||
RawHandleWrapperHolder(Arc::new(Mutex::new(None))),
|
|
||||||
));
|
|
||||||
if let Some(primary_cursor_options) = &self.primary_cursor_options {
|
|
||||||
entity_commands.insert(primary_cursor_options.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.exit_condition {
|
match self.exit_condition {
|
||||||
|
|||||||
@ -162,5 +162,5 @@ impl HasDisplayHandle for ThreadLockedRawWindowHandleWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Holder of the [`RawHandleWrapper`] with wrappers, to allow use in asynchronous context
|
/// Holder of the [`RawHandleWrapper`] with wrappers, to allow use in asynchronous context
|
||||||
#[derive(Debug, Clone, Component)]
|
#[derive(Debug, Clone, Component, Default)]
|
||||||
pub struct RawHandleWrapperHolder(pub Arc<Mutex<Option<RawHandleWrapper>>>);
|
pub struct RawHandleWrapperHolder(pub Arc<Mutex<Option<RawHandleWrapper>>>);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ use {
|
|||||||
#[cfg(all(feature = "serialize", feature = "bevy_reflect"))]
|
#[cfg(all(feature = "serialize", feature = "bevy_reflect"))]
|
||||||
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
||||||
|
|
||||||
use crate::VideoMode;
|
use crate::{RawHandleWrapperHolder, VideoMode};
|
||||||
|
|
||||||
/// Default string used for the window title.
|
/// Default string used for the window title.
|
||||||
///
|
///
|
||||||
@ -53,6 +53,7 @@ static DEFAULT_WINDOW_TITLE: LazyLock<String> = LazyLock::new(|| {
|
|||||||
derive(Reflect),
|
derive(Reflect),
|
||||||
reflect(Component, Debug, Default, PartialEq, Clone)
|
reflect(Component, Debug, Default, PartialEq, Clone)
|
||||||
)]
|
)]
|
||||||
|
#[require(Window, RawHandleWrapperHolder)]
|
||||||
pub struct PrimaryWindow;
|
pub struct PrimaryWindow;
|
||||||
|
|
||||||
/// Reference to a [`Window`], whether it be a direct link to a specific entity or
|
/// Reference to a [`Window`], whether it be a direct link to a specific entity or
|
||||||
@ -469,8 +470,8 @@ impl Default for Window {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
title: DEFAULT_WINDOW_TITLE.to_owned(),
|
title: DEFAULT_WINDOW_TITLE.to_owned(),
|
||||||
|
present_mode: PresentMode::default(),
|
||||||
name: None,
|
name: None,
|
||||||
present_mode: Default::default(),
|
|
||||||
mode: Default::default(),
|
mode: Default::default(),
|
||||||
position: Default::default(),
|
position: Default::default(),
|
||||||
resolution: Default::default(),
|
resolution: Default::default(),
|
||||||
|
|||||||
@ -81,13 +81,7 @@ impl Display for Scene {
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.init_resource::<AppStatus>()
|
.init_resource::<AppStatus>()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Anisotropy Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, create_material_variants)
|
.add_systems(Update, create_material_variants)
|
||||||
.add_systems(Update, animate_light)
|
.add_systems(Update, animate_light)
|
||||||
|
|||||||
@ -122,13 +122,7 @@ impl MaterialExtension for CustomDecalExtension {
|
|||||||
/// Entry point.
|
/// Entry point.
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugin)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Clustered Decals Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_plugins(MaterialPlugin::<
|
.add_plugins(MaterialPlugin::<
|
||||||
ExtendedMaterial<StandardMaterial, CustomDecalExtension>,
|
ExtendedMaterial<StandardMaterial, CustomDecalExtension>,
|
||||||
>::default())
|
>::default())
|
||||||
|
|||||||
@ -52,13 +52,7 @@ struct AppSettings {
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.init_resource::<AppSettings>()
|
.init_resource::<AppSettings>()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Depth of Field Example".to_string(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, tweak_scene)
|
.add_systems(Update, tweak_scene)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
|
|||||||
@ -15,13 +15,7 @@ use bevy::{
|
|||||||
/// Entry point.
|
/// Entry point.
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Fog Volumes Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.insert_resource(AmbientLight::NONE)
|
.insert_resource(AmbientLight::NONE)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, rotate_camera)
|
.add_systems(Update, rotate_camera)
|
||||||
|
|||||||
@ -147,13 +147,7 @@ struct VoxelVisualizationIrradianceVolumeInfo {
|
|||||||
fn main() {
|
fn main() {
|
||||||
// Create the example app.
|
// Create the example app.
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Irradiance Volumes Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_plugins(MaterialPlugin::<VoxelVisualizationMaterial>::default())
|
.add_plugins(MaterialPlugin::<VoxelVisualizationMaterial>::default())
|
||||||
.init_resource::<AppStatus>()
|
.init_resource::<AppStatus>()
|
||||||
.init_resource::<ExampleAssets>()
|
.init_resource::<ExampleAssets>()
|
||||||
|
|||||||
@ -105,13 +105,7 @@ struct HelpText;
|
|||||||
/// Entry point.
|
/// Entry point.
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Light Textures Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.init_resource::<AppStatus>()
|
.init_resource::<AppStatus>()
|
||||||
.add_event::<WidgetClickEvent<Selection>>()
|
.add_event::<WidgetClickEvent<Selection>>()
|
||||||
.add_event::<WidgetClickEvent<Visibility>>()
|
.add_event::<WidgetClickEvent<Visibility>>()
|
||||||
|
|||||||
@ -116,13 +116,7 @@ const INITIAL_SPHERE_POSITION: Vec3 = vec3(0.0, 0.5233223, 0.0);
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Mixed Lighting Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_plugins(MeshPickingPlugin)
|
.add_plugins(MeshPickingPlugin)
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
color: ClearColor::default().0,
|
color: ClearColor::default().0,
|
||||||
|
|||||||
@ -182,13 +182,6 @@ fn main() {
|
|||||||
App::new()
|
App::new()
|
||||||
.add_plugins(
|
.add_plugins(
|
||||||
DefaultPlugins
|
DefaultPlugins
|
||||||
.set(WindowPlugin {
|
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Occlusion Culling Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
})
|
|
||||||
.set(RenderPlugin {
|
.set(RenderPlugin {
|
||||||
debug_flags: render_debug_flags,
|
debug_flags: render_debug_flags,
|
||||||
..default()
|
..default()
|
||||||
|
|||||||
@ -113,13 +113,7 @@ enum AppSetting {
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.init_resource::<AppStatus>()
|
.init_resource::<AppStatus>()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Percentage Closer Soft Shadows Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_event::<WidgetClickEvent<AppSetting>>()
|
.add_event::<WidgetClickEvent<AppSetting>>()
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, widgets::handle_ui_interactions::<AppSetting>)
|
.add_systems(Update, widgets::handle_ui_interactions::<AppSetting>)
|
||||||
|
|||||||
@ -27,13 +27,7 @@ struct AppSettings {
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.init_resource::<AppSettings>()
|
.init_resource::<AppSettings>()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Chromatic Aberration Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, handle_keyboard_input)
|
.add_systems(Update, handle_keyboard_input)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
|
|||||||
@ -24,13 +24,7 @@ use bevy::{
|
|||||||
/// Initializes the example.
|
/// Initializes the example.
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Scrolling Fog".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.insert_resource(DirectionalLightShadowMap { size: 4096 })
|
.insert_resource(DirectionalLightShadowMap { size: 4096 })
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, scroll_fog)
|
.add_systems(Update, scroll_fog)
|
||||||
|
|||||||
@ -50,13 +50,7 @@ enum TintType {
|
|||||||
/// The entry point.
|
/// The entry point.
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Specular Tint Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.init_resource::<AppAssets>()
|
.init_resource::<AppAssets>()
|
||||||
.init_resource::<AppStatus>()
|
.init_resource::<AppStatus>()
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
|
|||||||
@ -101,13 +101,7 @@ fn main() {
|
|||||||
App::new()
|
App::new()
|
||||||
.insert_resource(DefaultOpaqueRendererMethod::deferred())
|
.insert_resource(DefaultOpaqueRendererMethod::deferred())
|
||||||
.init_resource::<AppSettings>()
|
.init_resource::<AppSettings>()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Screen Space Reflections Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_plugins(MaterialPlugin::<ExtendedMaterial<StandardMaterial, Water>>::default())
|
.add_plugins(MaterialPlugin::<ExtendedMaterial<StandardMaterial, Water>>::default())
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, rotate_model)
|
.add_systems(Update, rotate_model)
|
||||||
|
|||||||
@ -71,13 +71,7 @@ struct AppStatus {
|
|||||||
// Sets up the app.
|
// Sets up the app.
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Visibility Range Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.init_resource::<AppStatus>()
|
.init_resource::<AppStatus>()
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
|
|||||||
@ -74,13 +74,7 @@ fn main() {
|
|||||||
let args = Args::from_args(&[], &[]).unwrap();
|
let args = Args::from_args(&[], &[]).unwrap();
|
||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Animation Graph Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, (setup_assets, setup_scene, setup_ui))
|
.add_systems(Startup, (setup_assets, setup_scene, setup_ui))
|
||||||
.add_systems(Update, init_animations)
|
.add_systems(Update, init_animations)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
|
|||||||
@ -94,13 +94,7 @@ struct MaskGroupState {
|
|||||||
// The application entry point.
|
// The application entry point.
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Animation Masks Example".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, (setup_scene, setup_ui))
|
.add_systems(Startup, (setup_scene, setup_ui))
|
||||||
.add_systems(Update, setup_animation_graph_once_loaded)
|
.add_systems(Update, setup_animation_graph_once_loaded)
|
||||||
.add_systems(Update, handle_button_toggles)
|
.add_systems(Update, handle_button_toggles)
|
||||||
|
|||||||
@ -12,13 +12,7 @@ use std::f32::consts::PI;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "morph targets".to_string(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
brightness: 150.0,
|
brightness: 150.0,
|
||||||
..default()
|
..default()
|
||||||
|
|||||||
@ -89,7 +89,7 @@ fn main() {
|
|||||||
// Not strictly necessary, as the inclusion of ScheduleRunnerPlugin below
|
// Not strictly necessary, as the inclusion of ScheduleRunnerPlugin below
|
||||||
// replaces the bevy_winit app runner and so a window is never created.
|
// replaces the bevy_winit app runner and so a window is never created.
|
||||||
.set(WindowPlugin {
|
.set(WindowPlugin {
|
||||||
primary_window: None,
|
spawn_primary_window: false,
|
||||||
// Don’t automatically exit due to having no windows.
|
// Don’t automatically exit due to having no windows.
|
||||||
// Instead, the code in `update()` will explicitly produce an `AppExit` event.
|
// Instead, the code in `update()` will explicitly produce an `AppExit` event.
|
||||||
exit_condition: bevy::window::ExitCondition::DontExit,
|
exit_condition: bevy::window::ExitCondition::DontExit,
|
||||||
|
|||||||
@ -5,23 +5,23 @@
|
|||||||
//! - `App::run()` will never return on iOS and Web.
|
//! - `App::run()` will never return on iOS and Web.
|
||||||
//! - It is not possible to recreate a window after the event loop has been terminated.
|
//! - It is not possible to recreate a window after the event loop has been terminated.
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::{prelude::*, window::PrimaryWindow};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Running Bevy App");
|
println!("Running Bevy App");
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
.add_observer(configure_window)
|
||||||
title: "Close the window to return to the main function".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Update, system)
|
.add_systems(Update, system)
|
||||||
.run();
|
.run();
|
||||||
println!("Bevy App has exited. We are back in our main function.");
|
println!("Bevy App has exited. We are back in our main function.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "Close the window to return to the main function".into();
|
||||||
|
}
|
||||||
|
|
||||||
fn system() {
|
fn system() {
|
||||||
info!("Logging from Bevy App");
|
info!("Logging from Bevy App");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,19 +18,11 @@ use bevy::window::CompositeAlphaMode;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Desk Toy".into(),
|
|
||||||
transparent: true,
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
composite_alpha_mode: CompositeAlphaMode::PostMultiplied,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.insert_resource(ClearColor(WINDOW_CLEAR_COLOR))
|
.insert_resource(ClearColor(WINDOW_CLEAR_COLOR))
|
||||||
.insert_resource(WindowTransparency(false))
|
.insert_resource(WindowTransparency(false))
|
||||||
.insert_resource(CursorWorldPos(None))
|
.insert_resource(CursorWorldPos(None))
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
@ -51,6 +43,16 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "Bevy Desk Toy".into();
|
||||||
|
window.transparent = true;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
window.composite_alpha_mode = CompositeAlphaMode::PostMultiplied;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Whether the window is transparent
|
/// Whether the window is transparent
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
struct WindowTransparency(bool);
|
struct WindowTransparency(bool);
|
||||||
|
|||||||
@ -15,35 +15,16 @@ use bevy::{
|
|||||||
/// `main.rs`.
|
/// `main.rs`.
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins(
|
app.add_plugins(DefaultPlugins.set(LogPlugin {
|
||||||
DefaultPlugins
|
|
||||||
.set(LogPlugin {
|
|
||||||
// This will show some log events from Bevy to the native logger.
|
// This will show some log events from Bevy to the native logger.
|
||||||
level: Level::DEBUG,
|
level: Level::DEBUG,
|
||||||
filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(),
|
filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
}))
|
||||||
.set(WindowPlugin {
|
|
||||||
primary_window: Some(Window {
|
|
||||||
resizable: false,
|
|
||||||
mode: WindowMode::BorderlessFullscreen(MonitorSelection::Primary),
|
|
||||||
// on iOS, gestures must be enabled.
|
|
||||||
// This doesn't work on Android
|
|
||||||
recognize_rotation_gesture: true,
|
|
||||||
// Only has an effect on iOS
|
|
||||||
prefers_home_indicator_hidden: true,
|
|
||||||
// Only has an effect on iOS
|
|
||||||
prefers_status_bar_hidden: true,
|
|
||||||
// Only has an effect on iOS
|
|
||||||
preferred_screen_edges_deferring_system_gestures: ScreenEdge::Bottom,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
// Make the winit loop wait more aggressively when no user input is received
|
// Make the winit loop wait more aggressively when no user input is received
|
||||||
// This can help reduce cpu usage on mobile devices
|
// This can help reduce cpu usage on mobile devices
|
||||||
.insert_resource(WinitSettings::mobile())
|
.insert_resource(WinitSettings::mobile())
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, (setup_scene, setup_music))
|
.add_systems(Startup, (setup_scene, setup_music))
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
@ -58,6 +39,22 @@ pub fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
|
||||||
|
window.resizable = false;
|
||||||
|
window.mode = WindowMode::BorderlessFullscreen(MonitorSelection::Primary);
|
||||||
|
// on iOS, gestures must be enabled.
|
||||||
|
// This doesn't work on Android
|
||||||
|
window.recognize_rotation_gesture = true;
|
||||||
|
// Only has an effect on iOS
|
||||||
|
window.prefers_home_indicator_hidden = true;
|
||||||
|
// Only has an effect on iOS
|
||||||
|
window.prefers_status_bar_hidden = true;
|
||||||
|
// Only has an effect on iOS
|
||||||
|
window.preferred_screen_edges_deferring_system_gestures = ScreenEdge::Bottom;
|
||||||
|
}
|
||||||
|
|
||||||
fn touch_camera(
|
fn touch_camera(
|
||||||
window: Query<&Window>,
|
window: Query<&Window>,
|
||||||
mut touches: EventReader<TouchInput>,
|
mut touches: EventReader<TouchInput>,
|
||||||
|
|||||||
@ -14,6 +14,7 @@ use bevy::{
|
|||||||
texture::GpuImage,
|
texture::GpuImage,
|
||||||
Render, RenderApp, RenderStartup, RenderSystems,
|
Render, RenderApp, RenderStartup, RenderSystems,
|
||||||
},
|
},
|
||||||
|
window::PrimaryWindow,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
@ -28,28 +29,25 @@ fn main() {
|
|||||||
App::new()
|
App::new()
|
||||||
.insert_resource(ClearColor(Color::BLACK))
|
.insert_resource(ClearColor(Color::BLACK))
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins
|
DefaultPlugins.set(ImagePlugin::default_nearest()),
|
||||||
.set(WindowPlugin {
|
|
||||||
primary_window: Some(Window {
|
|
||||||
resolution: (
|
|
||||||
(SIZE.0 * DISPLAY_FACTOR) as f32,
|
|
||||||
(SIZE.1 * DISPLAY_FACTOR) as f32,
|
|
||||||
)
|
|
||||||
.into(),
|
|
||||||
// uncomment for unthrottled FPS
|
|
||||||
// present_mode: bevy::window::PresentMode::AutoNoVsync,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
})
|
|
||||||
.set(ImagePlugin::default_nearest()),
|
|
||||||
GameOfLifeComputePlugin,
|
GameOfLifeComputePlugin,
|
||||||
))
|
))
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, switch_textures)
|
.add_systems(Update, switch_textures)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = (
|
||||||
|
(SIZE.0 * DISPLAY_FACTOR) as f32,
|
||||||
|
(SIZE.1 * DISPLAY_FACTOR) as f32,
|
||||||
|
)
|
||||||
|
.into();
|
||||||
|
// Optional: set the present mode to AutoNoVsync for unthrottled FPS
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
|
fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
|
||||||
let mut image = Image::new_fill(
|
let mut image = Image::new_fill(
|
||||||
Extent3d {
|
Extent3d {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use bevy::{
|
|||||||
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
||||||
},
|
},
|
||||||
sprite::AlphaMode2d,
|
sprite::AlphaMode2d,
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
use rand::{seq::SliceRandom, Rng, SeedableRng};
|
use rand::{seq::SliceRandom, Rng, SeedableRng};
|
||||||
@ -132,16 +132,7 @@ fn main() {
|
|||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "BevyMark".into(),
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
|
||||||
.with_scale_factor_override(1.0),
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
@ -154,6 +145,7 @@ fn main() {
|
|||||||
count: 0,
|
count: 0,
|
||||||
color: Color::WHITE,
|
color: Color::WHITE,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(FixedUpdate, scheduled_spawner)
|
.add_systems(FixedUpdate, scheduled_spawner)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
@ -171,6 +163,13 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "BevyMark".to_string();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
struct BirdScheduled {
|
struct BirdScheduled {
|
||||||
waves: usize,
|
waves: usize,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use std::time::Duration;
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -22,20 +22,13 @@ fn main() {
|
|||||||
.add_plugins((
|
.add_plugins((
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
|
||||||
.with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
))
|
))
|
||||||
.insert_resource(WinitSettings {
|
.insert_resource(WinitSettings {
|
||||||
focused_mode: UpdateMode::Continuous,
|
focused_mode: UpdateMode::Continuous,
|
||||||
unfocused_mode: UpdateMode::Continuous,
|
unfocused_mode: UpdateMode::Continuous,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
@ -48,6 +41,12 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
assets: Res<AssetServer>,
|
assets: Res<AssetServer>,
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use bevy::{
|
|||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
text::TextColor,
|
text::TextColor,
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,14 +73,7 @@ fn main() {
|
|||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
|
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
@ -88,6 +81,7 @@ fn main() {
|
|||||||
focused_mode: UpdateMode::Continuous,
|
focused_mode: UpdateMode::Continuous,
|
||||||
unfocused_mode: UpdateMode::Continuous,
|
unfocused_mode: UpdateMode::Continuous,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Update, (button_system, set_text_colors_changed));
|
.add_systems(Update, (button_system, set_text_colors_changed));
|
||||||
|
|
||||||
if !args.no_camera {
|
if !args.no_camera {
|
||||||
@ -129,6 +123,12 @@ fn main() {
|
|||||||
app.insert_resource(args).run();
|
app.insert_resource(args).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn set_text_colors_changed(mut colors: Query<&mut TextColor>) {
|
fn set_text_colors_changed(mut colors: Query<&mut TextColor>) {
|
||||||
for mut text_color in colors.iter_mut() {
|
for mut text_color in colors.iter_mut() {
|
||||||
text_color.set_changed();
|
text_color.set_changed();
|
||||||
|
|||||||
@ -6,24 +6,24 @@ use bevy::{
|
|||||||
math::ops::{cos, sin},
|
math::ops::{cos, sin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::camera::Viewport,
|
render::camera::Viewport,
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
.add_observer(configure_window)
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, rotate_cameras)
|
.add_systems(Update, rotate_cameras)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
const CAMERA_ROWS: usize = 4;
|
const CAMERA_ROWS: usize = 4;
|
||||||
const CAMERA_COLS: usize = 4;
|
const CAMERA_COLS: usize = 4;
|
||||||
const NUM_LIGHTS: usize = 5;
|
const NUM_LIGHTS: usize = 5;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ use bevy::{
|
|||||||
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
||||||
view::{NoCpuCulling, NoFrustumCulling, NoIndirectDrawing},
|
view::{NoCpuCulling, NoFrustumCulling, NoIndirectDrawing},
|
||||||
},
|
},
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
use rand::{seq::SliceRandom, Rng, SeedableRng};
|
use rand::{seq::SliceRandom, Rng, SeedableRng};
|
||||||
@ -106,14 +106,7 @@ fn main() {
|
|||||||
|
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
@ -121,6 +114,7 @@ fn main() {
|
|||||||
focused_mode: UpdateMode::Continuous,
|
focused_mode: UpdateMode::Continuous,
|
||||||
unfocused_mode: UpdateMode::Continuous,
|
unfocused_mode: UpdateMode::Continuous,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, (move_camera, print_mesh_count));
|
.add_systems(Update, (move_camera, print_mesh_count));
|
||||||
|
|
||||||
@ -131,6 +125,12 @@ fn main() {
|
|||||||
app.insert_resource(args).run();
|
app.insert_resource(args).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
const WIDTH: usize = 200;
|
const WIDTH: usize = 200;
|
||||||
const HEIGHT: usize = 200;
|
const HEIGHT: usize = 200;
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use bevy::{
|
|||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
pbr::CascadeShadowConfigBuilder,
|
pbr::CascadeShadowConfigBuilder,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,16 +41,7 @@ fn main() {
|
|||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "🦊🦊🦊 Many Foxes! 🦊🦊🦊".into(),
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
|
||||||
.with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
@ -64,6 +55,7 @@ fn main() {
|
|||||||
moving: true,
|
moving: true,
|
||||||
sync: args.sync,
|
sync: args.sync,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
@ -76,6 +68,13 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "🦊🦊🦊 Many Foxes! 🦊🦊🦊".to_string();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
struct Animations {
|
struct Animations {
|
||||||
node_indices: Vec<AnimationNodeIndex>,
|
node_indices: Vec<AnimationNodeIndex>,
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use std::f32::consts::TAU;
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
diagnostic::{Diagnostic, DiagnosticsStore, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{Diagnostic, DiagnosticsStore, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14,15 +14,7 @@ const SYSTEM_COUNT: u32 = 10;
|
|||||||
fn main() {
|
fn main() {
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Many Debug Lines".to_string(),
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
@ -34,6 +26,7 @@ fn main() {
|
|||||||
line_count: 50_000,
|
line_count: 50_000,
|
||||||
fancy: false,
|
fancy: false,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, (input, ui_system));
|
.add_systems(Update, (input, ui_system));
|
||||||
|
|
||||||
@ -44,6 +37,13 @@ fn main() {
|
|||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "Many Debug Lines".to_string();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Resource, Debug)]
|
#[derive(Resource, Debug)]
|
||||||
struct Config {
|
struct Config {
|
||||||
line_count: u32,
|
line_count: u32,
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use bevy::{
|
|||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
text::{LineBreak, TextBounds},
|
text::{LineBreak, TextBounds},
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,14 +40,7 @@ fn main() {
|
|||||||
|
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
@ -55,6 +48,7 @@ fn main() {
|
|||||||
focused_mode: UpdateMode::Continuous,
|
focused_mode: UpdateMode::Continuous,
|
||||||
unfocused_mode: UpdateMode::Continuous,
|
unfocused_mode: UpdateMode::Continuous,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup);
|
.add_systems(Startup, setup);
|
||||||
|
|
||||||
if args.recompute_text {
|
if args.recompute_text {
|
||||||
@ -64,6 +58,12 @@ fn main() {
|
|||||||
app.insert_resource(args).run();
|
app.insert_resource(args).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, args: Res<Args>) {
|
fn setup(mut commands: Commands, args: Res<Args>) {
|
||||||
warn!(include_str!("warning_string.txt"));
|
warn!(include_str!("warning_string.txt"));
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use bevy::{
|
|||||||
pbr::{ExtractedPointLight, GlobalClusterableObjectMeta},
|
pbr::{ExtractedPointLight, GlobalClusterableObjectMeta},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{camera::ScalingMode, Render, RenderApp, RenderSystems},
|
render::{camera::ScalingMode, Render, RenderApp, RenderSystems},
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
@ -18,16 +18,7 @@ use rand::{thread_rng, Rng};
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
|
||||||
.with_scale_factor_override(1.0),
|
|
||||||
title: "many_lights".into(),
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
LogVisibleLights,
|
LogVisibleLights,
|
||||||
@ -36,11 +27,19 @@ fn main() {
|
|||||||
focused_mode: UpdateMode::Continuous,
|
focused_mode: UpdateMode::Continuous,
|
||||||
unfocused_mode: UpdateMode::Continuous,
|
unfocused_mode: UpdateMode::Continuous,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, (move_camera, print_light_count))
|
.add_systems(Update, (move_camera, print_light_count))
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "many_lights".to_string();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use argh::FromArgs;
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
window::{PresentMode, WindowPlugin, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
};
|
};
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
@ -24,25 +24,24 @@ fn main() {
|
|||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
|
||||||
.with_scale_factor_override(1.0),
|
|
||||||
title: "many_materials".into(),
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
.insert_resource(args)
|
.insert_resource(args)
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, animate_materials)
|
.add_systems(Update, animate_materials)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.title = "many_materials".into();
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
args: Res<Args>,
|
args: Res<Args>,
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use bevy::{
|
|||||||
color::palettes::css::*,
|
color::palettes::css::*,
|
||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -33,20 +33,13 @@ fn main() {
|
|||||||
.add_plugins((
|
.add_plugins((
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
|
||||||
.with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
))
|
))
|
||||||
.insert_resource(WinitSettings {
|
.insert_resource(WinitSettings {
|
||||||
focused_mode: UpdateMode::Continuous,
|
focused_mode: UpdateMode::Continuous,
|
||||||
unfocused_mode: UpdateMode::Continuous,
|
unfocused_mode: UpdateMode::Continuous,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
@ -55,6 +48,12 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, assets: Res<AssetServer>, color_tint: Res<ColorTint>) {
|
fn setup(mut commands: Commands, assets: Res<AssetServer>, color_tint: Res<ColorTint>) {
|
||||||
warn!(include_str!("warning_string.txt"));
|
warn!(include_str!("warning_string.txt"));
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use bevy::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
render::view::NoFrustumCulling,
|
render::view::NoFrustumCulling,
|
||||||
text::FontAtlasSets,
|
text::FontAtlasSets,
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
};
|
};
|
||||||
|
|
||||||
use argh::FromArgs;
|
use argh::FromArgs;
|
||||||
@ -72,16 +72,10 @@ fn main() {
|
|||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
))
|
))
|
||||||
.init_resource::<FontHandle>()
|
.init_resource::<FontHandle>()
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, (move_camera, print_counts));
|
.add_systems(Update, (move_camera, print_counts));
|
||||||
|
|
||||||
@ -101,6 +95,12 @@ impl Default for PrintingTimer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, font: Res<FontHandle>, args: Res<Args>) {
|
fn setup(mut commands: Commands, font: Res<FontHandle>, args: Res<Args>) {
|
||||||
warn!(include_str!("warning_string.txt"));
|
warn!(include_str!("warning_string.txt"));
|
||||||
|
|
||||||
|
|||||||
@ -7,22 +7,14 @@ use bevy::{
|
|||||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
text::{LineBreak, TextBounds},
|
text::{LineBreak, TextBounds},
|
||||||
window::{PresentMode, WindowResolution},
|
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||||
winit::{UpdateMode, WinitSettings},
|
winit::{UpdateMode, WinitSettings},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
|
||||||
.with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
@ -30,11 +22,18 @@ fn main() {
|
|||||||
focused_mode: UpdateMode::Continuous,
|
focused_mode: UpdateMode::Continuous,
|
||||||
unfocused_mode: UpdateMode::Continuous,
|
unfocused_mode: UpdateMode::Continuous,
|
||||||
})
|
})
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, spawn)
|
.add_systems(Startup, spawn)
|
||||||
.add_systems(Update, update_text_bounds)
|
.add_systems(Update, update_text_bounds)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
warn!(include_str!("warning_string.txt"));
|
warn!(include_str!("warning_string.txt"));
|
||||||
|
|
||||||
|
|||||||
@ -189,7 +189,7 @@ fn main() {
|
|||||||
.insert_resource(cfg)
|
.insert_resource(cfg)
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins.set(WindowPlugin {
|
||||||
primary_window: None,
|
spawn_primary_window: false,
|
||||||
exit_condition: ExitCondition::DontExit,
|
exit_condition: ExitCondition::DontExit,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -18,6 +18,7 @@ use bevy::{
|
|||||||
experimental::occlusion_culling::OcclusionCulling,
|
experimental::occlusion_culling::OcclusionCulling,
|
||||||
primitives::{Aabb, Sphere},
|
primitives::{Aabb, Sphere},
|
||||||
},
|
},
|
||||||
|
window::PrimaryWindow,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[path = "../../helpers/camera_controller.rs"]
|
#[path = "../../helpers/camera_controller.rs"]
|
||||||
@ -65,15 +66,7 @@ fn main() {
|
|||||||
|
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
DefaultPlugins
|
DefaultPlugins.set(AssetPlugin {
|
||||||
.set(WindowPlugin {
|
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "bevy scene viewer".to_string(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
})
|
|
||||||
.set(AssetPlugin {
|
|
||||||
file_path: std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_string()),
|
file_path: std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_string()),
|
||||||
// Allow scenes to be loaded from anywhere on disk
|
// Allow scenes to be loaded from anywhere on disk
|
||||||
unapproved_path_mode: UnapprovedPathMode::Allow,
|
unapproved_path_mode: UnapprovedPathMode::Allow,
|
||||||
@ -84,6 +77,7 @@ fn main() {
|
|||||||
MorphViewerPlugin,
|
MorphViewerPlugin,
|
||||||
))
|
))
|
||||||
.insert_resource(args)
|
.insert_resource(args)
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(PreUpdate, setup_scene_after_load);
|
.add_systems(PreUpdate, setup_scene_after_load);
|
||||||
|
|
||||||
@ -98,6 +92,11 @@ fn main() {
|
|||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "Bevy Scene Viewer".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_scene(scene_path: String) -> (String, usize) {
|
fn parse_scene(scene_path: String) -> (String, usize) {
|
||||||
if scene_path.contains('#') {
|
if scene_path.contains('#') {
|
||||||
let gltf_and_scene = scene_path.split('#').collect::<Vec<_>>();
|
let gltf_and_scene = scene_path.split('#').collect::<Vec<_>>();
|
||||||
|
|||||||
@ -7,13 +7,7 @@ const MARGIN: Val = Val::Px(12.);
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Bevy Flex Layout Example".to_string(),
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, spawn_layout)
|
.add_systems(Startup, spawn_layout)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
//! Demonstrates how CSS Grid layout can be used to lay items out in a 2D grid
|
//! Demonstrates how CSS Grid layout can be used to lay items out in a 2D grid
|
||||||
use bevy::{color::palettes::css::*, prelude::*};
|
use bevy::{color::palettes::css::*, prelude::*, window::PrimaryWindow};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
.add_observer(configure_window)
|
||||||
resolution: [800., 600.].into(),
|
|
||||||
title: "Bevy CSS Grid Layout Example".to_string(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, spawn_layout)
|
.add_systems(Startup, spawn_layout)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "Bevy CSS Grid Layout Example".to_string();
|
||||||
|
window.resolution = [800., 600.].into();
|
||||||
|
}
|
||||||
|
|
||||||
fn spawn_layout(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn spawn_layout(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let font = asset_server.load("fonts/FiraSans-Bold.ttf");
|
let font = asset_server.load("fonts/FiraSans-Bold.ttf");
|
||||||
commands.spawn(Camera2d);
|
commands.spawn(Camera2d);
|
||||||
|
|||||||
@ -7,26 +7,23 @@ use bevy::{
|
|||||||
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin},
|
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
ui::widget::TextUiWriter,
|
ui::widget::TextUiWriter,
|
||||||
window::PresentMode,
|
window::{PresentMode, PrimaryWindow},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((DefaultPlugins, FrameTimeDiagnosticsPlugin::default()))
|
||||||
DefaultPlugins.set(WindowPlugin {
|
.add_observer(configure_window)
|
||||||
primary_window: Some(Window {
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
|
||||||
))
|
|
||||||
.add_systems(Startup, infotext_system)
|
.add_systems(Startup, infotext_system)
|
||||||
.add_systems(Update, change_text_system)
|
.add_systems(Update, change_text_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct TextChanges;
|
struct TextChanges;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
//! This example demonstrates text wrapping and use of the `LineBreakOn` property.
|
//! This example demonstrates text wrapping and use of the `LineBreakOn` property.
|
||||||
|
|
||||||
use argh::FromArgs;
|
use argh::FromArgs;
|
||||||
use bevy::{prelude::*, text::LineBreak, window::WindowResolution, winit::WinitSettings};
|
use bevy::{
|
||||||
|
prelude::*,
|
||||||
|
text::LineBreak,
|
||||||
|
window::{PrimaryWindow, WindowResolution},
|
||||||
|
winit::WinitSettings,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(FromArgs, Resource)]
|
#[derive(FromArgs, Resource)]
|
||||||
/// `text_wrap_debug` demonstrates text wrapping and use of the `LineBreakOn` property
|
/// `text_wrap_debug` demonstrates text wrapping and use of the `LineBreakOn` property
|
||||||
@ -16,30 +21,30 @@ struct Args {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
App::new()
|
||||||
|
.add_plugins(DefaultPlugins)
|
||||||
|
.insert_resource(WinitSettings::desktop_app())
|
||||||
|
.add_observer(configure_window)
|
||||||
|
.add_systems(Startup, spawn)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn configure_window(
|
||||||
|
trigger: On<Add, PrimaryWindow>,
|
||||||
|
mut window: Query<&mut Window>,
|
||||||
|
mut commands: Commands,
|
||||||
|
) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
// `from_env` panics on the web
|
// `from_env` panics on the web
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
let args = Args::from_args(&[], &[]).unwrap();
|
let args = Args::from_args(&[], &[]).unwrap();
|
||||||
|
|
||||||
let window = if let Some(scale_factor) = args.scale_factor {
|
if let Some(scale_factor) = args.scale_factor {
|
||||||
Window {
|
window.resolution = WindowResolution::default().with_scale_factor_override(scale_factor);
|
||||||
resolution: WindowResolution::default().with_scale_factor_override(scale_factor),
|
|
||||||
..Default::default()
|
|
||||||
}
|
}
|
||||||
} else {
|
commands.insert_resource(UiScale(args.ui_scale));
|
||||||
Window::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
App::new()
|
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
|
||||||
primary_window: Some(window),
|
|
||||||
..Default::default()
|
|
||||||
}))
|
|
||||||
.insert_resource(WinitSettings::desktop_app())
|
|
||||||
.insert_resource(UiScale(args.ui_scale))
|
|
||||||
.add_systems(Startup, spawn)
|
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
//! and then switches between them once per second using the `Display` style property.
|
//! and then switches between them once per second using the `Display` style property.
|
||||||
//! If there are no problems both layouts should be identical, except for the color of the margin changing which is used to signal that the displayed UI node tree has changed
|
//! If there are no problems both layouts should be identical, except for the color of the margin changing which is used to signal that the displayed UI node tree has changed
|
||||||
//! (red for viewport, yellow for pixel).
|
//! (red for viewport, yellow for pixel).
|
||||||
use bevy::{color::palettes::css::*, prelude::*};
|
use bevy::{color::palettes::css::*, prelude::*, window::PrimaryWindow};
|
||||||
|
|
||||||
const PALETTE: [Srgba; 10] = [
|
const PALETTE: [Srgba; 10] = [
|
||||||
RED, YELLOW, WHITE, BEIGE, AQUA, CRIMSON, NAVY, AZURE, LIME, BLACK,
|
RED, YELLOW, WHITE, BEIGE, AQUA, CRIMSON, NAVY, AZURE, LIME, BLACK,
|
||||||
@ -20,22 +20,20 @@ enum Coords {
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(UiScale(2.0))
|
.insert_resource(UiScale(2.0))
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
.add_observer(configure_window)
|
||||||
title: "Viewport Coordinates Debug".to_string(),
|
|
||||||
// This example relies on these specific viewport dimensions, so let's explicitly
|
|
||||||
// define them.
|
|
||||||
resolution: [1280., 720.].into(),
|
|
||||||
resizable: false,
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, update)
|
.add_systems(Update, update)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "Viewport Coordinates Debug".to_string();
|
||||||
|
window.resolution = [1280., 720.].into();
|
||||||
|
window.resizable = false;
|
||||||
|
}
|
||||||
|
|
||||||
fn update(
|
fn update(
|
||||||
mut timer: Local<f32>,
|
mut timer: Local<f32>,
|
||||||
mut visible_tree: Local<Coords>,
|
mut visible_tree: Local<Coords>,
|
||||||
|
|||||||
@ -2,26 +2,28 @@
|
|||||||
//! If you build this, and hit 'P' it should toggle on/off the mouse's passthrough.
|
//! If you build this, and hit 'P' it should toggle on/off the mouse's passthrough.
|
||||||
//! Note: this example will not work on following platforms: iOS / Android / Web / X11. Window fall through is not supported there.
|
//! Note: this example will not work on following platforms: iOS / Android / Web / X11. Window fall through is not supported there.
|
||||||
|
|
||||||
use bevy::{prelude::*, window::CursorOptions};
|
use bevy::{
|
||||||
|
prelude::*,
|
||||||
|
window::{CursorOptions, PrimaryWindow, WindowLevel},
|
||||||
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(ClearColor(Color::NONE)) // Use a transparent window, to make effects obvious.
|
.insert_resource(ClearColor(Color::NONE)) // Use a transparent window, to make effects obvious.
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
.add_observer(configure_window)
|
||||||
// Set the window's parameters, note we're setting the window to always be on top.
|
|
||||||
transparent: true,
|
|
||||||
decorations: true,
|
|
||||||
window_level: bevy::window::WindowLevel::AlwaysOnTop,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, toggle_mouse_passthrough) // This allows us to hit 'P' to toggle on/off the mouse's passthrough
|
.add_systems(Update, toggle_mouse_passthrough) // This allows us to hit 'P' to toggle on/off the mouse's passthrough
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.transparent = true;
|
||||||
|
window.decorations = true;
|
||||||
|
window.window_level = WindowLevel::AlwaysOnTop;
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
// UI camera
|
// UI camera
|
||||||
commands.spawn(Camera2d);
|
commands.spawn(Camera2d);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
window::{PresentMode, RequestRedraw, WindowPlugin},
|
window::{PresentMode, PrimaryWindow, RequestRedraw},
|
||||||
winit::{EventLoopProxyWrapper, WakeUp, WinitSettings},
|
winit::{EventLoopProxyWrapper, WakeUp, WinitSettings},
|
||||||
};
|
};
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
@ -22,14 +22,8 @@ fn main() {
|
|||||||
unfocused_mode: bevy::winit::UpdateMode::reactive_low_power(Duration::from_millis(10)),
|
unfocused_mode: bevy::winit::UpdateMode::reactive_low_power(Duration::from_millis(10)),
|
||||||
})
|
})
|
||||||
.insert_resource(ExampleMode::Game)
|
.insert_resource(ExampleMode::Game)
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
.add_observer(configure_window)
|
||||||
// Turn off vsync to maximize CPU/GPU usage
|
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, test_setup::setup)
|
.add_systems(Startup, test_setup::setup)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
@ -43,6 +37,12 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
// Turn off vsync to maximize CPU/GPU usage
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Resource, Debug)]
|
#[derive(Resource, Debug)]
|
||||||
enum ExampleMode {
|
enum ExampleMode {
|
||||||
Game,
|
Game,
|
||||||
|
|||||||
@ -9,7 +9,7 @@ use bevy::{
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||||
primary_window: None,
|
spawn_primary_window: false,
|
||||||
exit_condition: ExitCondition::DontExit,
|
exit_condition: ExitCondition::DontExit,
|
||||||
..default()
|
..default()
|
||||||
}))
|
}))
|
||||||
|
|||||||
@ -1,20 +1,18 @@
|
|||||||
//! This example illustrates how to override the window scale factor imposed by the
|
//! This example illustrates how to override the window scale factor imposed by the
|
||||||
//! operating system.
|
//! operating system.
|
||||||
|
|
||||||
use bevy::{prelude::*, window::WindowResolution};
|
use bevy::{
|
||||||
|
prelude::*,
|
||||||
|
window::{PrimaryWindow, WindowResolution},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct CustomText;
|
struct CustomText;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
.add_observer(configure_window)
|
||||||
resolution: WindowResolution::new(500., 300.).with_scale_factor_override(1.0),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
@ -23,6 +21,11 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands) {
|
fn setup(mut commands: Commands) {
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera2d);
|
commands.spawn(Camera2d);
|
||||||
|
|||||||
@ -4,32 +4,38 @@
|
|||||||
//! [documentation](https://docs.rs/bevy/latest/bevy/prelude/struct.Window.html#structfield.transparent)
|
//! [documentation](https://docs.rs/bevy/latest/bevy/prelude/struct.Window.html#structfield.transparent)
|
||||||
//! for more details.
|
//! for more details.
|
||||||
|
|
||||||
use bevy::prelude::*;
|
|
||||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||||
use bevy::window::CompositeAlphaMode;
|
use bevy::window::CompositeAlphaMode;
|
||||||
|
use bevy::{prelude::*, window::PrimaryWindow};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
// 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,
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
composite_alpha_mode: CompositeAlphaMode::PostMultiplied,
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
composite_alpha_mode: CompositeAlphaMode::PreMultiplied,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
// ClearColor must have 0 alpha, otherwise some color will bleed through
|
// ClearColor must have 0 alpha, otherwise some color will bleed through
|
||||||
.insert_resource(ClearColor(Color::NONE))
|
.insert_resource(ClearColor(Color::NONE))
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
|
||||||
|
// Setting `transparent` allows the `ClearColor`'s alpha value to take effect
|
||||||
|
window.transparent = true;
|
||||||
|
// Disabling window decorations to make it feel more like a widget than a window
|
||||||
|
window.decorations = false;
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
window.composite_alpha_mode = CompositeAlphaMode::PostMultiplied;
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
window.composite_alpha_mode = CompositeAlphaMode::PreMultiplied;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera2d);
|
commands.spawn(Camera2d);
|
||||||
commands.spawn(Sprite::from_image(asset_server.load("branding/icon.png")));
|
commands.spawn(Sprite::from_image(asset_server.load("branding/icon.png")));
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
//!
|
//!
|
||||||
//! The `start_drag_resize()` function behaves similarly but permits a window to
|
//! The `start_drag_resize()` function behaves similarly but permits a window to
|
||||||
//! be resized.
|
//! be resized.
|
||||||
use bevy::{math::CompassOctant, prelude::*};
|
use bevy::{math::CompassOctant, prelude::*, window::PrimaryWindow};
|
||||||
|
|
||||||
/// Determine what do on left click.
|
/// Determine what do on left click.
|
||||||
#[derive(Resource, Debug)]
|
#[derive(Resource, Debug)]
|
||||||
@ -41,20 +41,20 @@ const DIRECTIONS: [CompassOctant; 8] = [
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
decorations: false,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.insert_resource(ResizeDir(7))
|
.insert_resource(ResizeDir(7))
|
||||||
.insert_resource(LeftClickAction::Move)
|
.insert_resource(LeftClickAction::Move)
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, (handle_input, move_or_resize_windows))
|
.add_systems(Update, (handle_input, move_or_resize_windows))
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.decorations = false;
|
||||||
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands) {
|
fn setup(mut commands: Commands) {
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn(Camera3d::default());
|
commands.spawn(Camera3d::default());
|
||||||
|
|||||||
@ -7,7 +7,8 @@ use bevy::{
|
|||||||
diagnostic::{FrameCount, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
diagnostic::{FrameCount, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
window::{
|
window::{
|
||||||
CursorGrabMode, CursorOptions, PresentMode, SystemCursorIcon, WindowLevel, WindowTheme,
|
CursorGrabMode, CursorOptions, PresentMode, PrimaryWindow, SystemCursorIcon, WindowLevel,
|
||||||
|
WindowTheme,
|
||||||
},
|
},
|
||||||
winit::cursor::CursorIcon,
|
winit::cursor::CursorIcon,
|
||||||
};
|
};
|
||||||
@ -15,32 +16,11 @@ use bevy::{
|
|||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins,
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "I am a window!".into(),
|
|
||||||
name: Some("bevy.app".into()),
|
|
||||||
resolution: (500., 300.).into(),
|
|
||||||
present_mode: PresentMode::AutoVsync,
|
|
||||||
// Tells Wasm to resize the window according to the available canvas
|
|
||||||
fit_canvas_to_parent: true,
|
|
||||||
// Tells Wasm not to override default event handling, like F5, Ctrl+R etc.
|
|
||||||
prevent_default_event_handling: false,
|
|
||||||
window_theme: Some(WindowTheme::Dark),
|
|
||||||
enabled_buttons: bevy::window::EnabledButtons {
|
|
||||||
maximize: false,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
// This will spawn an invisible window
|
|
||||||
// The window will be made visible in the make_visible() system after 3 frames.
|
|
||||||
// This is useful when you want to avoid the white window that shows up before the GPU is ready to render the app.
|
|
||||||
visible: false,
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
LogDiagnosticsPlugin::default(),
|
LogDiagnosticsPlugin::default(),
|
||||||
FrameTimeDiagnosticsPlugin::default(),
|
FrameTimeDiagnosticsPlugin::default(),
|
||||||
))
|
))
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, init_cursor_icons)
|
.add_systems(Startup, init_cursor_icons)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
@ -58,6 +38,25 @@ fn main() {
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
window.title = "I am a window!".into();
|
||||||
|
window.name = Some("bevy.app".into());
|
||||||
|
window.resolution = (500., 300.).into();
|
||||||
|
// Tells Wasm to resize the window according to the available canvas
|
||||||
|
window.fit_canvas_to_parent = true;
|
||||||
|
// Tells Wasm not to override default event handling, like F5, Ctrl+R etc.
|
||||||
|
window.prevent_default_event_handling = false;
|
||||||
|
window.window_theme = Some(WindowTheme::Dark);
|
||||||
|
window.enabled_buttons.maximize = false;
|
||||||
|
// This will spawn an invisible window
|
||||||
|
// The window will be made visible in the make_visible() system after 3 frames.
|
||||||
|
// This is useful when you want to avoid the white window that shows up before the GPU is ready to render the app.
|
||||||
|
window.visible = false;
|
||||||
|
|
||||||
|
window.present_mode = PresentMode::AutoNoVsync;
|
||||||
|
}
|
||||||
|
|
||||||
fn make_visible(mut window: Single<&mut Window>, frames: Res<FrameCount>) {
|
fn make_visible(mut window: Single<&mut Window>, frames: Res<FrameCount>) {
|
||||||
// The delay may be different for your app or system.
|
// The delay may be different for your app or system.
|
||||||
if frames.0 == 3 {
|
if frames.0 == 3 {
|
||||||
|
|||||||
@ -6,13 +6,7 @@ fn main() {
|
|||||||
// TODO: Combine this with `resizing` once multiple_windows is simpler than
|
// TODO: Combine this with `resizing` once multiple_windows is simpler than
|
||||||
// it is currently.
|
// it is currently.
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins)
|
||||||
primary_window: Some(Window {
|
|
||||||
title: "Minimizing".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}))
|
|
||||||
.add_systems(Startup, (setup_3d, setup_2d))
|
.add_systems(Startup, (setup_3d, setup_2d))
|
||||||
.add_systems(Update, minimize_automatically)
|
.add_systems(Update, minimize_automatically)
|
||||||
.run();
|
.run();
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
//! A test to confirm that `bevy` allows setting the window to arbitrary small sizes
|
//! A test to confirm that `bevy` allows setting the window to arbitrary small sizes
|
||||||
//! This is run in CI to ensure that this doesn't regress again.
|
//! This is run in CI to ensure that this doesn't regress again.
|
||||||
|
|
||||||
use bevy::{prelude::*, window::WindowResolution};
|
use bevy::{
|
||||||
|
prelude::*,
|
||||||
|
window::{PrimaryWindow, WindowResolution},
|
||||||
|
};
|
||||||
|
|
||||||
// The smallest size reached is 1x1, as X11 doesn't support windows with a 0 dimension
|
// The smallest size reached is 1x1, as X11 doesn't support windows with a 0 dimension
|
||||||
// TODO: Add a check for platforms other than X11 for 0xk and kx0, despite those currently unsupported on CI.
|
// TODO: Add a check for platforms other than X11 for 0xk and kx0, despite those currently unsupported on CI.
|
||||||
@ -19,27 +22,25 @@ struct Dimensions {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(
|
.add_plugins(DefaultPlugins)
|
||||||
DefaultPlugins.set(WindowPlugin {
|
|
||||||
primary_window: Some(Window {
|
|
||||||
resolution: WindowResolution::new(MAX_WIDTH as f32, MAX_HEIGHT as f32)
|
|
||||||
.with_scale_factor_override(1.0),
|
|
||||||
title: "Resizing".into(),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.insert_resource(Dimensions {
|
.insert_resource(Dimensions {
|
||||||
width: MAX_WIDTH,
|
width: MAX_WIDTH,
|
||||||
height: MAX_HEIGHT,
|
height: MAX_HEIGHT,
|
||||||
})
|
})
|
||||||
.insert_resource(ContractingY)
|
.insert_resource(ContractingY)
|
||||||
|
.add_observer(configure_window)
|
||||||
.add_systems(Startup, (setup_3d, setup_2d))
|
.add_systems(Startup, (setup_3d, setup_2d))
|
||||||
.add_systems(Update, (change_window_size, sync_dimensions))
|
.add_systems(Update, (change_window_size, sync_dimensions))
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut Window>) {
|
||||||
|
let mut window = window.get_mut(trigger.target()).unwrap();
|
||||||
|
|
||||||
|
window.resolution =
|
||||||
|
WindowResolution::new(MAX_WIDTH as f32, MAX_HEIGHT as f32).with_scale_factor_override(1.0);
|
||||||
|
window.title = "Resizing".into();
|
||||||
|
}
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
enum Phase {
|
enum Phase {
|
||||||
ContractingY,
|
ContractingY,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user