pub struct Viewport { /* private fields */ }Expand description
A viewport defined by a glium::Rect structure, with associated 2D and 3D
cameras
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn new(rect: Rect) -> Self
pub fn new(rect: Rect) -> Self
Create a new viewport with the given Rect
§Panics
Width or height are zero:
ⓘ
let mut viewport = Viewport::new (glium::Rect {
left: 0, bottom: 0, width: 0, height: 0
});Width or height are greater than u16::MAX (65535):
ⓘ
let mut viewport = Viewport::new (glium::Rect {
left: 0, bottom: 0, width: 65536, height: 65536
});Sourcepub fn with_pose_3d(rect: Rect, pose: Pose3<f32>) -> Self
pub fn with_pose_3d(rect: Rect, pose: Pose3<f32>) -> Self
Also initializes self.camera3d with position and orientation
pub const fn rect(&self) -> &Rect
pub const fn camera2d(&self) -> Option<&Camera2d>
pub const fn camera3d(&self) -> Option<&Camera3d>
Sourcepub fn set_rect(&mut self, rect: Rect)
pub fn set_rect(&mut self, rect: Rect)
Should be called when screen resolution changes.
§Panics
Width and height must be less than or equal to u16::MAX (65535):
ⓘ
viewport.set_rect (glium::Rect {
left: 0, bottom: 0,
width: 100_000, height: 100_000 // panics
});Width or height are zero:
ⓘ
viewport.set_rect (glium::Rect {
left: 0, bottom: 0,
width: 0, height: 0 // panics
});pub fn camera2d_set_position(&mut self, position: Point2<f32>)
pub fn camera2d_set_zoom(&mut self, zoom: f32)
pub fn camera2d_move_local(&mut self, dx: f32, dy: f32)
pub fn camera2d_move_origin_to_bottom_left(&mut self)
pub fn camera3d_set_position(&mut self, position: Point3<f32>)
pub fn camera3d_set_orientation(&mut self, orientation: Rotation3<f32>)
pub fn camera3d_look_at(&mut self, target: Point3<f32>)
pub fn camera3d_move_local_xy(&mut self, dx: f32, dy: f32, dz: f32)
pub fn camera3d_rotate( &mut self, dyaw: Rad<f32>, dpitch: Rad<f32>, droll: Rad<f32>, )
pub fn camera3d_scale_fovy_or_zoom(&mut self, zoom: f32)
Sourcepub fn draw_parameters(&self) -> DrawParameters<'_>
pub fn draw_parameters(&self) -> DrawParameters<'_>
Returns default glium draw parameters with the viewport set to the current rectangle
Sourcepub fn draw_parameters_blend_invert(&self) -> DrawParameters<'_>
pub fn draw_parameters_blend_invert(&self) -> DrawParameters<'_>
Draw parameters that will result in ‘inverted’ colors (used by tile renderer)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin 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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
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 moreSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.