pub struct Camera<M> {
pub mode: M,
pub dims: Dims,
pub project: Mat4x4<ViewToProj>,
pub viewport: Mat4x4<NdcToScreen>,
}Expand description
Type to manage the world-to-viewport transformation.
Fields§
§mode: MThe movement mode of the camera.
dims: DimsViewport width and height.
project: Mat4x4<ViewToProj>Projection matrix.
viewport: Mat4x4<NdcToScreen>Viewport matrix.
Implementations§
Source§impl<M> Camera<M>
impl<M> Camera<M>
Sourcepub fn viewport(self, bounds: impl Into<Rect<u32>>) -> Self
pub fn viewport(self, bounds: impl Into<Rect<u32>>) -> Self
Sets the viewport bounds of this camera.
Sourcepub fn perspective(self, focal_ratio: f32, near_far: Range<f32>) -> Self
pub fn perspective(self, focal_ratio: f32, near_far: Range<f32>) -> Self
Sets up perspective projection.
Sourcepub fn orthographic(self, bounds: Range<Vec3>) -> Self
pub fn orthographic(self, bounds: Range<Vec3>) -> Self
Sets up orthographic projection.
Source§impl<M: Mode> Camera<M>
impl<M: Mode> Camera<M>
Sourcepub fn world_to_project(&self) -> Mat4x4<RealToProj<World>>
pub fn world_to_project(&self) -> Mat4x4<RealToProj<World>>
Returns the composed camera and projection matrix.
Sourcepub fn render<B, Vtx: Clone, Var: Vary, Uni: Copy, Shd>(
&self,
tris: impl AsRef<[Tri<usize>]>,
verts: impl AsRef<[Vtx]>,
to_world: &Mat4x4<RealToReal<3, B, World>>,
shader: &Shd,
uniform: Uni,
target: &mut impl Target,
ctx: &Context,
)where
Shd: for<'a> VertexShader<Vtx, (&'a Mat4x4<RealToProj<B>>, Uni), Output = Vertex<ClipVec, Var>> + FragmentShader<Var>,
pub fn render<B, Vtx: Clone, Var: Vary, Uni: Copy, Shd>(
&self,
tris: impl AsRef<[Tri<usize>]>,
verts: impl AsRef<[Vtx]>,
to_world: &Mat4x4<RealToReal<3, B, World>>,
shader: &Shd,
uniform: Uni,
target: &mut impl Target,
ctx: &Context,
)where
Shd: for<'a> VertexShader<Vtx, (&'a Mat4x4<RealToProj<B>>, Uni), Output = Vertex<ClipVec, Var>> + FragmentShader<Var>,
Renders the given geometry from the viewpoint of this camera.
Trait Implementations§
impl<M: Copy> Copy for Camera<M>
Auto Trait Implementations§
impl<M> Freeze for Camera<M>where
M: Freeze,
impl<M> RefUnwindSafe for Camera<M>where
M: RefUnwindSafe,
impl<M> Send for Camera<M>where
M: Send,
impl<M> Sync for Camera<M>where
M: Sync,
impl<M> Unpin for Camera<M>where
M: Unpin,
impl<M> UnwindSafe for Camera<M>where
M: UnwindSafe,
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