add missing image switch
This commit is contained in:
16
src/app.rs
16
src/app.rs
@@ -4,6 +4,7 @@ use bevy::{
|
||||
render::render_resource::{Extent3d, TextureDimension, TextureFormat, TextureUsages},
|
||||
window::PrimaryWindow,
|
||||
};
|
||||
use iyes_perf_ui::prelude::*;
|
||||
|
||||
use crate::render::pipeline::{TracerPipelinePlugin, TracerRenderTextures, TracerUniforms};
|
||||
|
||||
@@ -14,15 +15,28 @@ impl Plugin for Blackhole {
|
||||
app.register_type::<TracerRenderTextures>();
|
||||
|
||||
app.add_systems(Startup, setup);
|
||||
|
||||
app.add_plugins(TracerPipelinePlugin);
|
||||
app.insert_resource(TracerUniforms {
|
||||
sky_color: LinearRgba::BLUE,
|
||||
});
|
||||
|
||||
//Perf UI
|
||||
app.add_plugins(bevy::diagnostic::FrameTimeDiagnosticsPlugin::default())
|
||||
.add_plugins(bevy::diagnostic::EntityCountDiagnosticsPlugin)
|
||||
.add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin)
|
||||
.add_plugins(PerfUiPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>, window: Single<&Window, With<PrimaryWindow>>) {
|
||||
commands.spawn((
|
||||
PerfUiRoot::default(),
|
||||
PerfUiEntryFPS::default(),
|
||||
PerfUiEntryFPSWorst::default(),
|
||||
PerfUiEntryFrameTime::default(),
|
||||
PerfUiEntryFrameTimeWorst::default(),
|
||||
));
|
||||
|
||||
let size = window.physical_size();
|
||||
|
||||
let extent = Extent3d {
|
||||
|
||||
@@ -27,13 +27,6 @@ pub struct TracerLabel;
|
||||
#[reflect(Resource)]
|
||||
pub struct TracerRenderTextures(pub Handle<Image>, pub Handle<Image>);
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct TracerPipeline {
|
||||
pub texture_bind_group_layout: BindGroupLayout,
|
||||
pub init_pipeline: CachedComputePipelineId,
|
||||
pub update_pipeline: CachedComputePipelineId,
|
||||
}
|
||||
|
||||
#[derive(Resource, Clone, ExtractResource, ShaderType, Default)]
|
||||
pub struct TracerUniforms {
|
||||
pub sky_color: LinearRgba,
|
||||
@@ -47,7 +40,8 @@ impl Plugin for TracerPipelinePlugin {
|
||||
ExtractResourcePlugin::<TracerRenderTextures>::default(),
|
||||
ExtractResourcePlugin::<TracerUniforms>::default(),
|
||||
));
|
||||
app.init_resource::<TracerUniforms>();
|
||||
app.init_resource::<TracerUniforms>()
|
||||
.add_systems(Update, switch_textures);
|
||||
let render_app = app.sub_app_mut(RenderApp);
|
||||
|
||||
// render_app.add_systems(Startup, init_pipeline);
|
||||
@@ -64,6 +58,21 @@ impl Plugin for TracerPipelinePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn switch_textures(images: Res<TracerRenderTextures>, mut sprite: Single<&mut Sprite>) {
|
||||
if sprite.image == images.0 {
|
||||
sprite.image = images.1.clone();
|
||||
} else {
|
||||
sprite.image = images.0.clone();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct TracerPipeline {
|
||||
pub texture_bind_group_layout: BindGroupLayout,
|
||||
pub init_pipeline: CachedComputePipelineId,
|
||||
pub update_pipeline: CachedComputePipelineId,
|
||||
}
|
||||
|
||||
impl FromWorld for TracerPipeline {
|
||||
fn from_world(world: &mut World) -> Self {
|
||||
let render_device = world.resource::<RenderDevice>();
|
||||
@@ -109,6 +118,7 @@ impl FromWorld for TracerPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)] //Pending bevy update for RenderStartup schedule
|
||||
fn init_pipeline(
|
||||
mut commands: Commands,
|
||||
render_device: Res<RenderDevice>,
|
||||
|
||||
Reference in New Issue
Block a user