Function gl_utils::camera2d::ndc_2d_to_screen_2d [−][src]
pub fn ndc_2d_to_screen_2d(
screen_dimensions: Vector2<u16>,
ndc_coord: Point2<f32>
) -> Point2<i16>
Maps OpenGL NDC coordinates to screen coordinates based on a given screen resolution.
Examples
assert_eq!( ndc_2d_to_screen_2d (cgmath::vec2 (640, 480), (0.0, 0.0).into()), (320, 240).into() ); assert_eq!( ndc_2d_to_screen_2d (cgmath::vec2 (640, 480), (0.5, 0.1).into()), (480, 264).into() ); assert_eq!( ndc_2d_to_screen_2d (cgmath::vec2 (640, 480), (-1.0, -1.0).into()), (0, 0).into() ); assert_eq!( ndc_2d_to_screen_2d (cgmath::vec2 (640, 480), (-1.0, 1.0).into()), (0, 480).into() ); assert_eq!( ndc_2d_to_screen_2d (cgmath::vec2 (640, 480), (1.0, -1.0).into()), (640, 0).into() ); assert_eq!( ndc_2d_to_screen_2d (cgmath::vec2 (640, 480), (1.0, 1.0).into()), (640, 480).into() );