Update render_to_texture
example to use constructor
This commit is contained in:
parent
3faad8c7ee
commit
1fe04a5a38
@ -2,14 +2,7 @@
|
|||||||
|
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{prelude::*, render::view::RenderLayers};
|
||||||
prelude::*,
|
|
||||||
render::{
|
|
||||||
render_asset::RenderAssetUsages,
|
|
||||||
render_resource::{Extent3d, TextureDimension, TextureFormat, TextureUsages},
|
|
||||||
view::RenderLayers,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
@ -33,23 +26,8 @@ fn setup(
|
|||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
mut images: ResMut<Assets<Image>>,
|
mut images: ResMut<Assets<Image>>,
|
||||||
) {
|
) {
|
||||||
let size = Extent3d {
|
|
||||||
width: 512,
|
|
||||||
height: 512,
|
|
||||||
..default()
|
|
||||||
};
|
|
||||||
|
|
||||||
// This is the texture that will be rendered to.
|
// This is the texture that will be rendered to.
|
||||||
let mut image = Image::new_fill(
|
let image = Image::new_target_texture(512, 512);
|
||||||
size,
|
|
||||||
TextureDimension::D2,
|
|
||||||
&[0, 0, 0, 0],
|
|
||||||
TextureFormat::Bgra8UnormSrgb,
|
|
||||||
RenderAssetUsages::default(),
|
|
||||||
);
|
|
||||||
// You need to set these texture usage flags in order to use the image as a render target
|
|
||||||
image.texture_descriptor.usage =
|
|
||||||
TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST | TextureUsages::RENDER_ATTACHMENT;
|
|
||||||
|
|
||||||
let image_handle = images.add(image);
|
let image_handle = images.add(image);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user