pub struct Viewport<'a> { /* private fields */ }Expand description
Passive view description for rendering.
Declares camera, target, viewport, scissor, layer mask, and clear values.
setup_image_2d/setup_image_aspect_fit manufacture and retain an
orthographic camera internally; an externally borrowed camera supplied
later through Self::set_camera takes precedence again.
Donor: oa::Viewport.
Implementations§
Source§impl<'a> Viewport<'a>
impl<'a> Viewport<'a>
Sourcepub fn with_mode(mode: ViewportMode) -> Self
pub fn with_mode(mode: ViewportMode) -> Self
Create a viewport for mode.
Sourcepub fn set_mode(&mut self, mode: ViewportMode)
pub fn set_mode(&mut self, mode: ViewportMode)
Set the content mode.
Sourcepub const fn mode(&self) -> ViewportMode
pub const fn mode(&self) -> ViewportMode
Return the content mode.
Sourcepub fn set_camera(&mut self, camera: Option<&'a Camera>)
pub fn set_camera(&mut self, camera: Option<&'a Camera>)
Borrow an external camera, or None to clear one.
Sourcepub fn camera(&self) -> Option<&Camera>
pub fn camera(&self) -> Option<&Camera>
Return the active camera — the borrowed external camera when present, otherwise the internally manufactured one.
Sourcepub fn set_target(&mut self, target: Option<&'a Texture>)
pub fn set_target(&mut self, target: Option<&'a Texture>)
Borrow the render target, or None to clear it.
Sourcepub fn set_viewport(&mut self, viewport: ViewportDesc) -> Result<()>
pub fn set_viewport(&mut self, viewport: ViewportDesc) -> Result<()>
Set the viewport rectangle and depth range.
§Errors
Returns an error for non-positive dimensions or a depth range outside
[0, 1].
Sourcepub const fn viewport(&self) -> ViewportDesc
pub const fn viewport(&self) -> ViewportDesc
Return the configured viewport rectangle.
Sourcepub fn set_scissor(&mut self, scissor: ScissorDesc) -> Result<()>
pub fn set_scissor(&mut self, scissor: ScissorDesc) -> Result<()>
Sourcepub fn disable_scissor(&mut self)
pub fn disable_scissor(&mut self)
Disable scissor clipping.
Sourcepub const fn is_scissor_enabled(&self) -> bool
pub const fn is_scissor_enabled(&self) -> bool
Return whether scissor clipping is enabled.
Sourcepub const fn scissor(&self) -> ScissorDesc
pub const fn scissor(&self) -> ScissorDesc
Return the configured scissor rectangle.
Sourcepub fn set_layer_mask(&mut self, mask: RenderLayer)
pub fn set_layer_mask(&mut self, mask: RenderLayer)
Set the layer visibility mask.
Sourcepub const fn layer_mask(&self) -> RenderLayer
pub const fn layer_mask(&self) -> RenderLayer
Return the layer visibility mask.
Sourcepub const fn is_layer_visible(&self, layer: RenderLayer) -> bool
pub const fn is_layer_visible(&self, layer: RenderLayer) -> bool
Return whether layer passes the visibility mask.
Sourcepub const fn clear_color(&self) -> [f32; 4]
pub const fn clear_color(&self) -> [f32; 4]
Return the RGBA clear color.
Sourcepub fn set_clear_depth(&mut self, depth: f32) -> Result<()>
pub fn set_clear_depth(&mut self, depth: f32) -> Result<()>
Sourcepub const fn clear_depth(&self) -> f32
pub const fn clear_depth(&self) -> f32
Return the clear depth.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Return whether the viewport is complete and consistent: an active camera, a borrowed target, a valid viewport rectangle, a valid enabled scissor, and finite clear values.
Sourcepub fn setup_image_2d(
&mut self,
image_width: f32,
image_height: f32,
target: &'a Texture,
viewport: ViewportDesc,
) -> Result<()>
pub fn setup_image_2d( &mut self, image_width: f32, image_height: f32, target: &'a Texture, viewport: ViewportDesc, ) -> Result<()>
Set up orthographic 2D image viewing over target.
Manufactures an internal orthographic camera matching the image
extent; a later Self::set_camera overrides it again.
§Errors
Returns an error for non-positive image dimensions or an invalid viewport.
Sourcepub fn setup_image_aspect_fit(
&mut self,
image_width: f32,
image_height: f32,
window_width: f32,
window_height: f32,
target: &'a Texture,
) -> Result<()>
pub fn setup_image_aspect_fit( &mut self, image_width: f32, image_height: f32, window_width: f32, window_height: f32, target: &'a Texture, ) -> Result<()>
Set up aspect-fitted image display: a centered letterboxed viewport preserving the image aspect inside the window.
§Errors
Returns an error for non-positive dimensions, a window exceeding signed pixel coordinates, or a result that cannot be represented as a positive pixel rectangle.