Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_render/src/texture/manual_texture_view.rs
6596 views
1
use bevy_camera::ManualTextureViewHandle;
2
use bevy_ecs::{prelude::Component, resource::Resource};
3
use bevy_image::BevyDefault;
4
use bevy_math::UVec2;
5
use bevy_platform::collections::HashMap;
6
use bevy_render_macros::ExtractResource;
7
use wgpu::TextureFormat;
8
9
use crate::render_resource::TextureView;
10
11
/// A manually managed [`TextureView`] for use as a [`bevy_camera::RenderTarget`].
12
#[derive(Debug, Clone, Component)]
13
pub struct ManualTextureView {
14
pub texture_view: TextureView,
15
pub size: UVec2,
16
pub format: TextureFormat,
17
}
18
19
impl ManualTextureView {
20
pub fn with_default_format(texture_view: TextureView, size: UVec2) -> Self {
21
Self {
22
texture_view,
23
size,
24
format: TextureFormat::bevy_default(),
25
}
26
}
27
}
28
29
/// Stores manually managed [`ManualTextureView`]s for use as a [`bevy_camera::RenderTarget`].
30
#[derive(Default, Clone, Resource, ExtractResource)]
31
pub struct ManualTextureViews(HashMap<ManualTextureViewHandle, ManualTextureView>);
32
33
impl core::ops::Deref for ManualTextureViews {
34
type Target = HashMap<ManualTextureViewHandle, ManualTextureView>;
35
36
fn deref(&self) -> &Self::Target {
37
&self.0
38
}
39
}
40
41
impl core::ops::DerefMut for ManualTextureViews {
42
fn deref_mut(&mut self) -> &mut Self::Target {
43
&mut self.0
44
}
45
}
46
47