pub struct Viewport {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
pub min_depth: f32,
pub max_depth: f32,
pub origin: ViewportOrigin,
}Expand description
A rectangular viewport region mapping NDC to window coordinates.
Fields§
§x: f32X offset in pixels from the window origin.
y: f32Y offset in pixels from the window origin.
width: f32Width in pixels.
height: f32Height in pixels.
min_depth: f32Near depth range (typically 0.0).
max_depth: f32Far depth range (typically 1.0).
origin: ViewportOriginCoordinate origin convention.
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn new(width: f32, height: f32) -> Self
pub fn new(width: f32, height: f32) -> Self
Create a simple full-window viewport with standard depth range.
Sourcepub fn with_offset(
x: f32,
y: f32,
width: f32,
height: f32,
min_depth: f32,
max_depth: f32,
) -> Self
pub fn with_offset( x: f32, y: f32, width: f32, height: f32, min_depth: f32, max_depth: f32, ) -> Self
Create a viewport with an explicit offset and depth range.
Sourcepub fn aspect_ratio(&self) -> f32
pub fn aspect_ratio(&self) -> f32
Aspect ratio (width / height). Returns f32::INFINITY if height is zero.
Sourcepub fn is_portrait(&self) -> bool
pub fn is_portrait(&self) -> bool
Returns true if the viewport is taller than it is wide.
Sourcepub fn is_landscape(&self) -> bool
pub fn is_landscape(&self) -> bool
Returns true if the viewport is wider than it is tall.
Sourcepub fn has_valid_depth_range(&self) -> bool
pub fn has_valid_depth_range(&self) -> bool
Returns true if the depth range is valid (min < max, both in 0..=1).
Trait Implementations§
impl StructuralPartialEq for Viewport
Auto Trait Implementations§
impl Freeze for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin for Viewport
impl UnsafeUnpin for Viewport
impl UnwindSafe for Viewport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more