Struct gl_utils::camera3d::Projection3d[][src]

pub struct Projection3d {
    pub viewport_width: u16,
    pub viewport_height: u16,
    pub inner: Projection3dInner,
}

The 3D projection which can be either perspective or orthographic

Fields

Methods

impl Projection3d
[src]

Create a new 3D perspective projection

Panics

Viewport width or height is zero:

// panics:
let perspective = Projection3d::perspective (0, 240, cgmath::Deg (90.0).into());

If fovy is greater than or equal to $\pi$ radians:

// panics:
let perspective = Projection3d::perspective (320, 240, cgmath::Rad (4.0));

If fovy is less than or equal to $0.0$ radians:

// panics:
let perspective = Projection3d::perspective (320, 240, cgmath::Rad (0.0));

Create a new 3D orthographic projection

Panics

Viewport width or height is zero:

// panics:
let perspective = Projection3d::perspective (0, 240, cgmath::Deg (90.0).into());

If zoom is less than or equal to $0.0$:

let ortho = Projection3d::orthographic (320, 240, 0.0);  // panics

Returns a reference to the underlying projection matrix

Converts the inner projection type to an Orthographic projection with the given zoom; if already an orthographic projection this will modify the zoom

Converts the inner projection type to a Perspective projection with the given vertical FOV; if already a perspective projection this will modify the FOV

Sets the current viewport dimensions

Panics

Viewport width or height is zero:

let mut projection = Projection3d::perspective (320, 240, cgmath::Deg (90.0).into());
projection.set_viewport_dimensions (0, 240);  // panics

Multiply the current perspective vertical FOV or orthographic zoom by the given scale factor.

Will not increase vertical FOV greater than $\pi$ radians, nor will it decrease the zoom or vertical FOV to zero.

Panics

Panics if scale factor is zero or negative:

let mut camera3d = Camera3d::new (320, 240);
camera3d.projection3d.scale_fovy_or_zoom (-1.0);   // panics

Auto Trait Implementations

impl Send for Projection3d

impl Sync for Projection3d