[][src]Struct kiss3d::window::Window

pub struct Window { /* fields omitted */ }

Structure representing a window and a 3D scene.

This is the main interface with the 3d engine.

Implementations

impl Window[src]

pub fn should_close(&self) -> bool[src]

Indicates whether this window should be closed.

pub fn width(&self) -> u32[src]

The window width.

pub fn height(&self) -> u32[src]

The window height.

pub fn size(&self) -> Vector2<u32>[src]

The size of the window.

pub fn set_framerate_limit(&mut self, fps: Option<u64>)[src]

Sets the maximum number of frames per second. Cannot be 0. None means there is no limit.

pub fn set_title(&mut self, title: &str)[src]

Set window title

pub fn set_icon(
    &mut self,
    icon: impl GenericImage<Pixel = impl Pixel<Subpixel = u8>>
)
[src]

Set the window icon. On wasm this does nothing.


window.set_icon(image::open("foo.ico")?);

pub fn set_cursor_grab(&self, grab: bool)[src]

Set the cursor grabbing behaviour.

If cursor grabbing is on, the cursor is prevented from leaving the window. Does nothing on web platforms.

pub fn set_cursor_position(&self, x: f64, y: f64)[src]

pub fn hide_cursor(&self, hide: bool)[src]

pub fn close(&mut self)[src]

Closes the window.

pub fn hide(&mut self)[src]

Hides the window, without closing it. Use show to make it visible again.

pub fn show(&mut self)[src]

Makes the window visible. Use hide to hide it.

pub fn set_background_color(&mut self, r: f32, g: f32, b: f32)[src]

Sets the background color.

pub fn set_point_size(&mut self, pt_size: f32)[src]

Set the size of all subsequent points to be drawn until the next time this function is envoked.

pub fn set_line_width(&mut self, line_width: f32)[src]

Set the width of all subsequent lines to be drawn until the next time this function is envoked.

pub fn draw_line(
    &mut self,
    a: &Point3<f32>,
    b: &Point3<f32>,
    color: &Point3<f32>
)
[src]

Adds a 3D line to be drawn during the next render.

The line is being drawn only during the next frame after this call. Therefore, this call must be executed at as many frames as you want it to remain visible.

pub fn draw_planar_line(
    &mut self,
    a: &Point2<f32>,
    b: &Point2<f32>,
    color: &Point3<f32>
)
[src]

Draws a 2D line to be drawn during the next render.

The line is being drawn only during the next frame after this call. Therefore, this call must be executed at as many frames as you want it to remain visible.

pub fn draw_point(&mut self, pt: &Point3<f32>, color: &Point3<f32>)[src]

Adds a point to be drawn during the next frame.

pub fn draw_text(
    &mut self,
    text: &str,
    pos: &Point2<f32>,
    scale: f32,
    font: &Rc<Font>,
    color: &Point3<f32>
)
[src]

Adds a string to be drawn during the next frame.

pub fn remove(&mut self, sn: &mut SceneNode)[src]

👎 Deprecated:

Use remove_node instead.

Removes an object from the scene.

pub fn remove_node(&mut self, sn: &mut SceneNode)[src]

Removes an object from the scene.

pub fn remove_planar_node(&mut self, sn: &mut PlanarSceneNode)[src]

Removes a 2D object from the scene.

pub fn add_group(&mut self) -> SceneNode[src]

Adds a group to the scene.

A group is a node not containing any object.

pub fn add_planar_group(&mut self) -> PlanarSceneNode[src]

Adds a 2D group to the scene.

A group is a node not containing any object.

pub fn add_obj(
    &mut self,
    path: &Path,
    mtl_dir: &Path,
    scale: Vector3<f32>
) -> SceneNode
[src]

Adds an obj model to the scene.

Arguments

  • path - relative path to the obj file.
  • scale - scale to apply to the model.

pub fn add_mesh(
    &mut self,
    mesh: Rc<RefCell<Mesh>>,
    scale: Vector3<f32>
) -> SceneNode
[src]

Adds an unnamed mesh to the scene.

pub fn add_planar_mesh(
    &mut self,
    mesh: Rc<RefCell<PlanarMesh>>,
    scale: Vector2<f32>
) -> PlanarSceneNode
[src]

Adds an unnamed planar mesh to the scene.

pub fn add_trimesh(
    &mut self,
    descr: TriMesh<f32>,
    scale: Vector3<f32>
) -> SceneNode
[src]

Creates and adds a new object using the geometry generated by a given procedural generator. Creates and adds a new object using a mesh descriptor.

pub fn add_geom_with_name(
    &mut self,
    geometry_name: &str,
    scale: Vector3<f32>
) -> Option<SceneNode>
[src]

Creates and adds a new object using the geometry registered as geometry_name.

pub fn add_cube(&mut self, wx: f32, wy: f32, wz: f32) -> SceneNode[src]

Adds a cube to the scene. The cube is initially axis-aligned and centered at (0, 0, 0).

Arguments

  • wx - the cube extent along the x axis
  • wy - the cube extent along the y axis
  • wz - the cube extent along the z axis

pub fn add_sphere(&mut self, r: f32) -> SceneNode[src]

Adds a sphere to the scene. The sphere is initially centered at (0, 0, 0).

Arguments

  • r - the sphere radius

pub fn add_cone(&mut self, r: f32, h: f32) -> SceneNode[src]

Adds a cone to the scene. The cone is initially centered at (0, 0, 0) and points toward the positive y axis.

Arguments

  • h - the cone height
  • r - the cone base radius

pub fn add_cylinder(&mut self, r: f32, h: f32) -> SceneNode[src]

Adds a cylinder to the scene. The cylinder is initially centered at (0, 0, 0) and has its principal axis aligned with the y axis.

Arguments

  • h - the cylinder height
  • r - the cylinder base radius

pub fn add_capsule(&mut self, r: f32, h: f32) -> SceneNode[src]

Adds a capsule to the scene. The capsule is initially centered at (0, 0, 0) and has its principal axis aligned with the y axis.

Arguments

  • r - the capsule caps radius
  • h - the capsule height

pub fn add_planar_capsule(&mut self, r: f32, h: f32) -> PlanarSceneNode[src]

Adds a 2D capsule to the scene. The capsule is initially centered at (0, 0) and has its principal axis aligned with the y axis.

Arguments

  • r - the capsule caps radius
  • h - the capsule height

pub fn add_quad(
    &mut self,
    w: f32,
    h: f32,
    usubdivs: usize,
    vsubdivs: usize
) -> SceneNode
[src]

Adds a double-sided quad to the scene. The quad is initially centered at (0, 0, 0). The quad itself is composed of a user-defined number of triangles regularly spaced on a grid. This is the main way to draw height maps.

Arguments

  • w - the quad width.
  • h - the quad height.
  • wsubdivs - number of horizontal subdivisions. This correspond to the number of squares which will be placed horizontally on each line. Must not be 0.
  • hsubdivs - number of vertical subdivisions. This correspond to the number of squares which will be placed vertically on each line. Must not be 0. update.

pub fn add_quad_with_vertices(
    &mut self,
    vertices: &[Point3<f32>],
    nhpoints: usize,
    nvpoints: usize
) -> SceneNode
[src]

Adds a double-sided quad with the specified vertices.

pub fn add_texture(&mut self, path: &Path, name: &str) -> Rc<Texture>[src]

Load a texture from a file and return a reference to it.

pub fn add_rectangle(&mut self, wx: f32, wy: f32) -> PlanarSceneNode[src]

Adds a rectangle to the scene. The rectangle is initially axis-aligned and centered at (0, 0, 0).

Arguments

  • wx - the cube extent along the x axis
  • wy - the cube extent along the y axis

pub fn add_circle(&mut self, r: f32) -> PlanarSceneNode[src]

Adds a circle to the scene. The circle is initially centered at (0, 0, 0).

Arguments

  • r - the circle radius

pub fn add_convex_polygon(
    &mut self,
    polygon: Vec<Point2<f32>>,
    scale: Vector2<f32>
) -> PlanarSceneNode
[src]

Adds a convex polygon to the scene.

Arguments

  • r - the circle radius

pub fn is_closed(&self) -> bool[src]

Returns whether this window is closed or not.

pub fn scale_factor(&self) -> f64[src]

The scale factor of this screen.

pub fn set_light(&mut self, pos: Light)[src]

Sets the light mode. Only one light is supported.

pub fn new_hidden(title: &str) -> Window[src]

Opens a window, hide it then calls a user-defined procedure.

Arguments

  • title - the window title

pub fn new(title: &str) -> Window[src]

Opens a window then calls a user-defined procedure.

Arguments

  • title - the window title

pub fn new_with_size(title: &str, width: u32, height: u32) -> Window[src]

Opens a window with a custom size then calls a user-defined procedure.

Arguments

  • title - the window title.
  • width - the window width.
  • height - the window height.

pub fn new_with_setup(
    title: &str,
    width: u32,
    height: u32,
    setup: CanvasSetup
) -> Window
[src]

Opens a window with custom options for vsync and AA.

pub fn scene(&self) -> &SceneNode[src]

Reference to the scene associated with this window.

pub fn scene_mut(&mut self) -> &mut SceneNode[src]

Mutable reference to the scene associated with this window.

pub fn snap(&self, out: &mut Vec<u8>)[src]

Read the pixels currently displayed to the screen.

Arguments:

  • out - the output buffer. It is automatically resized.

pub fn snap_rect(
    &self,
    out: &mut Vec<u8>,
    x: usize,
    y: usize,
    width: usize,
    height: usize
)
[src]

Read a section of pixels from the screen

Arguments:

  • out - the output buffer. It is automatically resized
  • x, y, width, height - the rectangle to capture

pub fn snap_image(&self) -> ImageBuffer<Rgb<u8>, Vec<u8>>[src]

Get the current screen as an image

pub fn events(&self) -> EventManager[src]

Gets the events manager that gives access to an event iterator.

pub fn get_key(&self, key: Key) -> Action[src]

Gets the status of a key.

pub fn cursor_pos(&self) -> Option<(f64, f64)>[src]

Gets the last known position of the mouse.

The position of the mouse is automatically updated when the mouse moves over the canvas.

pub fn render_loop<S: State>(self, state: S)[src]

Runs the render and event loop until the window is closed.

pub fn render_with_state<S: State>(&mut self, state: &mut S) -> bool[src]

Render one frame using the specified state.

pub fn render(&mut self) -> bool[src]

Renders the scene using the default camera.

Returns false if the window should be closed.

pub fn render_with_effect(
    &mut self,
    effect: &mut dyn PostProcessingEffect
) -> bool
[src]

Render using a specific post processing effect.

Returns false if the window should be closed.

pub fn render_with_camera(&mut self, camera: &mut dyn Camera) -> bool[src]

Render using a specific camera.

Returns false if the window should be closed.

pub fn render_with_cameras(
    &mut self,
    camera: &mut dyn Camera,
    planar_camera: &mut dyn PlanarCamera
) -> bool
[src]

Render using a specific 2D and 3D camera.

Returns false if the window should be closed.

pub fn render_with_camera_and_effect(
    &mut self,
    camera: &mut dyn Camera,
    effect: &mut dyn PostProcessingEffect
) -> bool
[src]

Render using a specific camera and post processing effect.

Returns false if the window should be closed.

pub fn render_with_cameras_and_effect(
    &mut self,
    camera: &mut dyn Camera,
    planar_camera: &mut dyn PlanarCamera,
    effect: &mut dyn PostProcessingEffect
) -> bool
[src]

Render using a specific 2D and 3D camera and post processing effect.

Returns false if the window should be closed.

pub fn render_with(
    &mut self,
    camera: Option<&mut dyn Camera>,
    planar_camera: Option<&mut dyn PlanarCamera>,
    post_processing: Option<&mut dyn PostProcessingEffect>
) -> bool
[src]

Draws the scene with the given camera and post-processing effect.

Returns false if the window should be closed.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,