Struct three_d::core::render_target::RenderTarget
source · pub struct RenderTarget<'a> { /* private fields */ }Expand description
Adds additional functionality to clear, read from and write to the screen (see RenderTarget::screen) or a color texture and a depth texture at the same time (see RenderTarget::new). If you only want to perform an operation on either a color texture or depth texture, see ColorTarget and DepthTarget respectively. A render target purely adds functionality, so it can be created each time it is needed, the actual data is saved in the textures.
Implementations§
source§impl<'a> RenderTarget<'a>
impl<'a> RenderTarget<'a>
sourcepub fn screen(context: &Context, width: u32, height: u32) -> Self
pub fn screen(context: &Context, width: u32, height: u32) -> Self
Returns the screen render target for this context. Write to this render target to draw something on the screen.
sourcepub fn new(color: ColorTarget<'a>, depth: DepthTarget<'a>) -> Self
pub fn new(color: ColorTarget<'a>, depth: DepthTarget<'a>) -> Self
Constructs a new render target that enables rendering into the given ColorTarget and DepthTarget.
sourcepub fn clear(&self, clear_state: ClearState) -> &Self
pub fn clear(&self, clear_state: ClearState) -> &Self
Clears the color and depth of this render target as defined by the given clear state.
sourcepub fn clear_partially(
&self,
scissor_box: ScissorBox,
clear_state: ClearState
) -> &Self
pub fn clear_partially( &self, scissor_box: ScissorBox, clear_state: ClearState ) -> &Self
Clears the color and depth of the part of this render target that is inside the given scissor box.
sourcepub fn write(&self, render: impl FnOnce()) -> &Self
pub fn write(&self, render: impl FnOnce()) -> &Self
Writes whatever rendered in the render closure into this render target.
sourcepub fn write_partially(
&self,
scissor_box: ScissorBox,
render: impl FnOnce()
) -> &Self
pub fn write_partially( &self, scissor_box: ScissorBox, render: impl FnOnce() ) -> &Self
Writes whatever rendered in the render closure into the part of this render target defined by the scissor box.
sourcepub fn read_color<T: TextureDataType>(&self) -> Vec<T>
pub fn read_color<T: TextureDataType>(&self) -> Vec<T>
Returns the colors of the pixels in this render target. The number of channels per pixel and the data format for each channel is specified by the generic parameter.
Note: On web, the data format needs to match the data format of the color texture.
sourcepub fn read_color_partially<T: TextureDataType>(
&self,
scissor_box: ScissorBox
) -> Vec<T>
pub fn read_color_partially<T: TextureDataType>( &self, scissor_box: ScissorBox ) -> Vec<T>
Returns the colors of the pixels in this render target inside the given scissor box. The number of channels per pixel and the data format for each channel is specified by the generic parameter.
Note: On web, the data format needs to match the data format of the color texture.
sourcepub fn copy_from(
&self,
color_texture: ColorTexture<'_>,
depth_texture: DepthTexture<'_>,
viewport: Viewport,
write_mask: WriteMask
) -> &Self
👎Deprecated: use apply_screen_effect with a CopyEffect instead
pub fn copy_from( &self, color_texture: ColorTexture<'_>, depth_texture: DepthTexture<'_>, viewport: Viewport, write_mask: WriteMask ) -> &Self
sourcepub fn copy_partially_from(
&self,
scissor_box: ScissorBox,
color_texture: ColorTexture<'_>,
depth_texture: DepthTexture<'_>,
viewport: Viewport,
write_mask: WriteMask
) -> &Self
👎Deprecated: use apply_screen_effect_partially with a CopyEffect instead
pub fn copy_partially_from( &self, scissor_box: ScissorBox, color_texture: ColorTexture<'_>, depth_texture: DepthTexture<'_>, viewport: Viewport, write_mask: WriteMask ) -> &Self
Copies the content of the color and depth texture as limited by the ScissorBox and WriteMask to the part of this render target specified by the Viewport.
sourcepub fn copy_from_color(
&self,
color_texture: ColorTexture<'_>,
viewport: Viewport,
write_mask: WriteMask
) -> &Self
👎Deprecated: use apply_screen_effect with a CopyEffect instead
pub fn copy_from_color( &self, color_texture: ColorTexture<'_>, viewport: Viewport, write_mask: WriteMask ) -> &Self
sourcepub fn copy_partially_from_color(
&self,
scissor_box: ScissorBox,
color_texture: ColorTexture<'_>,
viewport: Viewport,
write_mask: WriteMask
) -> &Self
👎Deprecated: use apply_screen_effect_partially with a CopyEffect instead
pub fn copy_partially_from_color( &self, scissor_box: ScissorBox, color_texture: ColorTexture<'_>, viewport: Viewport, write_mask: WriteMask ) -> &Self
Copies the content of the color texture as limited by the ScissorBox and WriteMask to the part of this render target specified by the Viewport.
sourcepub fn copy_from_depth(
&self,
depth_texture: DepthTexture<'_>,
viewport: Viewport
) -> &Self
👎Deprecated: use apply_screen_effect with a CopyEffect instead
pub fn copy_from_depth( &self, depth_texture: DepthTexture<'_>, viewport: Viewport ) -> &Self
Copies the content of the depth texture to the part of this render target specified by the Viewport.
sourcepub fn copy_partially_from_depth(
&self,
scissor_box: ScissorBox,
depth_texture: DepthTexture<'_>,
viewport: Viewport
) -> &Self
👎Deprecated: use apply_screen_effect_partially with a CopyEffect instead
pub fn copy_partially_from_depth( &self, scissor_box: ScissorBox, depth_texture: DepthTexture<'_>, viewport: Viewport ) -> &Self
Copies the content of the depth texture as limited by the ScissorBox to the part of this render target specified by the Viewport.
sourcepub fn from_framebuffer(
context: &Context,
width: u32,
height: u32,
framebuffer: Framebuffer
) -> Self
pub fn from_framebuffer( context: &Context, width: u32, height: u32, framebuffer: Framebuffer ) -> Self
Creates a RenderTarget with the given low-level Framebuffer. Should only be used if the Framebuffer is used for something else, ie. to be able to combine this crate with functionality of another crate. Also see Self::into_framebuffer.
sourcepub fn into_framebuffer(self) -> Option<Framebuffer>
pub fn into_framebuffer(self) -> Option<Framebuffer>
Transforms this RenderTarget into a low-level Framebuffer. Should only be used if the Framebuffer is used for something else, ie. to be able to combine this crate with functionality of another crate. Also see Self::from_framebuffer.
source§impl<'a> RenderTarget<'a>
impl<'a> RenderTarget<'a>
sourcepub fn scissor_box(&self) -> ScissorBox
pub fn scissor_box(&self) -> ScissorBox
Returns the scissor box that encloses the entire target.
source§impl<'a> RenderTarget<'a>
impl<'a> RenderTarget<'a>
sourcepub fn render(
&self,
camera: &Camera,
objects: impl IntoIterator<Item = impl Object>,
lights: &[&dyn Light]
) -> &Self
pub fn render( &self, camera: &Camera, objects: impl IntoIterator<Item = impl Object>, lights: &[&dyn Light] ) -> &Self
Render the objects using the given camera and lights into this render target.
Use an empty array for the lights argument, if the objects does not require lights to be rendered.
Also, objects outside the camera frustum are not rendered and the objects are rendered in the order given by cmp_render_order.
sourcepub fn render_partially(
&self,
scissor_box: ScissorBox,
camera: &Camera,
objects: impl IntoIterator<Item = impl Object>,
lights: &[&dyn Light]
) -> &Self
pub fn render_partially( &self, scissor_box: ScissorBox, camera: &Camera, objects: impl IntoIterator<Item = impl Object>, lights: &[&dyn Light] ) -> &Self
Render the objects using the given camera and lights into the part of this render target defined by the scissor box.
Use an empty array for the lights argument, if the objects does not require lights to be rendered.
Also, objects outside the camera frustum are not rendered and the objects are rendered in the order given by cmp_render_order.
sourcepub fn render_with_material(
&self,
material: &dyn Material,
camera: &Camera,
geometries: impl IntoIterator<Item = impl Geometry>,
lights: &[&dyn Light]
) -> &Self
pub fn render_with_material( &self, material: &dyn Material, camera: &Camera, geometries: impl IntoIterator<Item = impl Geometry>, lights: &[&dyn Light] ) -> &Self
Render the geometries with the given Material using the given camera and lights into this render target.
Use an empty array for the lights argument, if the material does not require lights to be rendered.
sourcepub fn render_partially_with_material(
&self,
scissor_box: ScissorBox,
material: &dyn Material,
camera: &Camera,
geometries: impl IntoIterator<Item = impl Geometry>,
lights: &[&dyn Light]
) -> &Self
pub fn render_partially_with_material( &self, scissor_box: ScissorBox, material: &dyn Material, camera: &Camera, geometries: impl IntoIterator<Item = impl Geometry>, lights: &[&dyn Light] ) -> &Self
Render the geometries with the given Material using the given camera and lights into the part of this render target defined by the scissor box.
Use an empty array for the lights argument, if the material does not require lights to be rendered.
sourcepub fn render_with_effect(
&self,
effect: &dyn Effect,
camera: &Camera,
geometries: impl IntoIterator<Item = impl Geometry>,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
) -> &Self
pub fn render_with_effect( &self, effect: &dyn Effect, camera: &Camera, geometries: impl IntoIterator<Item = impl Geometry>, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> ) -> &Self
Render the geometries with the given Effect using the given camera and lights into this render target.
Use an empty array for the lights argument, if the effect does not require lights to be rendered.
sourcepub fn render_partially_with_effect(
&self,
scissor_box: ScissorBox,
effect: &dyn Effect,
camera: &Camera,
geometries: impl IntoIterator<Item = impl Geometry>,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
) -> &Self
pub fn render_partially_with_effect( &self, scissor_box: ScissorBox, effect: &dyn Effect, camera: &Camera, geometries: impl IntoIterator<Item = impl Geometry>, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> ) -> &Self
Render the geometries with the given Effect using the given camera and lights into the part of this render target defined by the scissor box.
Use an empty array for the lights argument, if the effect does not require lights to be rendered.
sourcepub fn apply_screen_material(
&self,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> &Self
pub fn apply_screen_material( &self, material: &dyn Material, camera: &Camera, lights: &[&dyn Light] ) -> &Self
Apply the given Material to this render target.
Use an empty array for the lights argument, if the material does not require lights to be rendered.
sourcepub fn apply_screen_material_partially(
&self,
scissor_box: ScissorBox,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> &Self
pub fn apply_screen_material_partially( &self, scissor_box: ScissorBox, material: &dyn Material, camera: &Camera, lights: &[&dyn Light] ) -> &Self
Apply the given Material to the part of this render target defined by the scissor box.
Use an empty array for the lights argument, if the material does not require lights to be rendered.
sourcepub fn apply_screen_effect(
&self,
effect: &dyn Effect,
camera: &Camera,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
) -> &Self
pub fn apply_screen_effect( &self, effect: &dyn Effect, camera: &Camera, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> ) -> &Self
Apply the given Effect to this render target.
Use an empty array for the lights argument, if the effect does not require lights to be rendered.
sourcepub fn apply_screen_effect_partially(
&self,
scissor_box: ScissorBox,
effect: &dyn Effect,
camera: &Camera,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
) -> &Self
pub fn apply_screen_effect_partially( &self, scissor_box: ScissorBox, effect: &dyn Effect, camera: &Camera, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> ) -> &Self
Apply the given Effect to the part of this render target defined by the scissor box.
Use an empty array for the lights argument, if the effect does not require lights to be rendered.