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
sourceimpl<'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>) -> ThreeDResult<Self>
pub fn new(color: ColorTarget<'a>, depth: DepthTarget<'a>) -> ThreeDResult<Self>
Constructs a new render target that enables rendering into the given ColorTarget and DepthTarget.
sourcepub fn clear(&self, clear_state: ClearState) -> ThreeDResult<&Self>
pub fn clear(&self, clear_state: ClearState) -> ThreeDResult<&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
) -> ThreeDResult<&Self>
pub fn clear_partially(
&self,
scissor_box: ScissorBox,
clear_state: ClearState
) -> ThreeDResult<&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() -> ThreeDResult<()>
) -> ThreeDResult<&Self>
pub fn write(
&self,
render: impl FnOnce() -> ThreeDResult<()>
) -> ThreeDResult<&Self>
Writes whatever rendered in the render closure into this render target.
sourcepub fn write_partially(
&self,
scissor_box: ScissorBox,
render: impl FnOnce() -> ThreeDResult<()>
) -> ThreeDResult<&Self>
pub fn write_partially(
&self,
scissor_box: ScissorBox,
render: impl FnOnce() -> ThreeDResult<()>
) -> ThreeDResult<&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) -> ThreeDResult<Vec<T>>
pub fn read_color<T: TextureDataType>(&self) -> ThreeDResult<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
) -> ThreeDResult<Vec<T>>
pub fn read_color_partially<T: TextureDataType>(
&self,
scissor_box: ScissorBox
) -> ThreeDResult<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 read_depth(&self) -> ThreeDResult<Vec<f32>>
pub fn read_depth(&self) -> ThreeDResult<Vec<f32>>
Returns the depth values in this render target.
sourcepub fn read_depth_partially(
&self,
scissor_box: ScissorBox
) -> ThreeDResult<Vec<f32>>
pub fn read_depth_partially(
&self,
scissor_box: ScissorBox
) -> ThreeDResult<Vec<f32>>
Returns the depth values in this render target inside the given scissor box.
sourcepub fn copy_from(
&self,
color_texture: Option<&Texture2D>,
depth_texture: Option<&DepthTargetTexture2D>,
scissor_box: ScissorBox,
write_mask: WriteMask
) -> ThreeDResult<&Self>
pub fn copy_from(
&self,
color_texture: Option<&Texture2D>,
depth_texture: Option<&DepthTargetTexture2D>,
scissor_box: ScissorBox,
write_mask: WriteMask
) -> ThreeDResult<&Self>
Copies the content of the color and depth texture to the specified scissor box of this render target. Only copies the channels given by the write mask.
sourcepub fn copy_from_array(
&self,
color_texture: Option<(&Texture2DArray, u32)>,
depth_texture: Option<(&DepthTargetTexture2DArray, u32)>,
scissor_box: ScissorBox,
write_mask: WriteMask
) -> ThreeDResult<&Self>
pub fn copy_from_array(
&self,
color_texture: Option<(&Texture2DArray, u32)>,
depth_texture: Option<(&DepthTargetTexture2DArray, u32)>,
scissor_box: ScissorBox,
write_mask: WriteMask
) -> ThreeDResult<&Self>
Copies the content of the given layers of the color and depth array textures to the specified viewport of this render target. Only copies the channels given by the write mask.
sourcepub fn scissor_box(&self) -> ScissorBox
pub fn scissor_box(&self) -> ScissorBox
Returns the scissor box that encloses the entire target.
sourceimpl<'a> RenderTarget<'a>
impl<'a> RenderTarget<'a>
sourcepub fn render(
&self,
camera: &Camera,
objects: &[&dyn Object],
lights: &[&dyn Light]
) -> ThreeDResult<&Self>
pub fn render(
&self,
camera: &Camera,
objects: &[&dyn Object],
lights: &[&dyn Light]
) -> ThreeDResult<&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: &[&dyn Object],
lights: &[&dyn Light]
) -> ThreeDResult<&Self>
pub fn render_partially(
&self,
scissor_box: ScissorBox,
camera: &Camera,
objects: &[&dyn Object],
lights: &[&dyn Light]
) -> ThreeDResult<&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.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for RenderTarget<'a>
impl<'a> !Send for RenderTarget<'a>
impl<'a> !Sync for RenderTarget<'a>
impl<'a> Unpin for RenderTarget<'a>
impl<'a> !UnwindSafe for RenderTarget<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more