Skip to content

Commit

Permalink
refactor: expose VelloCanvasMaterial
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Sep 16, 2023
1 parent 11189c1 commit b67295b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub use assets::{
VelloVector,
};
pub use debug::DebugVisualizations;
pub use rendertarget::VelloCanvasMaterial;

use crate::font::VelloFontLoader;

Expand All @@ -45,7 +46,7 @@ impl Plugin for BevyVelloPlugin {
app.add_asset::<VelloFont>()
.init_asset_loader::<VelloFontLoader>();
app.add_plugins((
Material2dPlugin::<rendertarget::SSTargetMaterial>::default(),
Material2dPlugin::<rendertarget::VelloCanvasMaterial>::default(),
DebugVisualizationsPlugin,
));
app.add_systems(Startup, rendertarget::setup_ss_rendertarget)
Expand Down
12 changes: 6 additions & 6 deletions src/rendertarget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ pub fn setup_image(

pub fn resize_rendertargets(
mut window_resize_events: EventReader<WindowResized>,
mut query: Query<(&mut SSRenderTarget, &Handle<SSTargetMaterial>)>,
mut query: Query<(&mut SSRenderTarget, &Handle<VelloCanvasMaterial>)>,
mut images: ResMut<Assets<Image>>,
mut target_materials: ResMut<Assets<SSTargetMaterial>>,
mut target_materials: ResMut<Assets<VelloCanvasMaterial>>,
windows: Query<&Window>,
) {
let Ok(window) = windows.get_single() else {
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn setup_ss_rendertarget(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut images: ResMut<Assets<Image>>,
mut custom_materials: ResMut<Assets<SSTargetMaterial>>,
mut custom_materials: ResMut<Assets<VelloCanvasMaterial>>,
windows: Query<&Window>,
// query_vectors: Query<Entity, Added<Handle<VelloVector>>>,
mut render_target_mesh_handle: Local<Option<Handle<Mesh>>>,
Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn setup_ss_rendertarget(
let texture_image = setup_image(&mut commands, &mut images, &window.resolution);
let render_target = SSRenderTarget(texture_image.clone());
let mesh = Mesh2dHandle(mesh_handle.clone());
let material = custom_materials.add(SSTargetMaterial {
let material = custom_materials.add(VelloCanvasMaterial {
texture: texture_image,
});

Expand All @@ -161,13 +161,13 @@ pub fn setup_ss_rendertarget(

#[derive(AsBindGroup, TypeUuid, TypePath, Clone)]
#[uuid = "b62bb455-a72c-4b56-87bb-81e0554e234f"]
pub struct SSTargetMaterial {
pub struct VelloCanvasMaterial {
#[texture(0)]
#[sampler(1)]
pub texture: Handle<Image>,
}

impl Material2d for SSTargetMaterial {
impl Material2d for VelloCanvasMaterial {
fn vertex_shader() -> ShaderRef {
SSRT_SHADER_HANDLE.typed().into()
}
Expand Down

0 comments on commit b67295b

Please sign in to comment.