pub struct Window { /* private fields */ }
Expand description

Structure representing a window and a 3D scene.

This is the main interface with the 3d engine.

Implementations

Indicates whether this window should be closed.

The window width.

The window height.

The size of the window.

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

Set window title

Set the window icon. On wasm this does nothing.


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

Set the cursor grabbing behaviour.

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

Set the cursor position.

Toggle the cursor visibility.

Closes the window.

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

Makes the window visible. Use hide to hide it.

Sets the background color.

Set the size of all points that will be rendered.

Unfortunately, not all point sizes are supported by all graphics drivers.

Set the width of all lines that will be rendered.

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.

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.

Adds a point to be drawn during the next frame.

Adds a string to be drawn during the next frame.

👎 Deprecated:

Use remove_node instead.

Removes an object from the scene.

Removes an object from the scene.

Removes a 2D object from the scene.

Adds a group to the scene.

A group is a node not containing any object.

Adds a 2D group to the scene.

A group is a node not containing any object.

Adds an obj model to the scene.

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

Adds an unnamed mesh to the scene.

Adds an unnamed planar mesh to the scene.

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.

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

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

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

Arguments
  • r - the sphere radius

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

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

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

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

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.

Adds a double-sided quad with the specified vertices.

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

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

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

Arguments
  • r - the circle radius

Adds a convex polygon to the scene.

Arguments
  • r - the circle radius

Returns whether this window is closed or not.

The scale factor of this screen.

Sets the light mode. Only one light is supported.

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

Arguments
  • title - the window title

Opens a window then calls a user-defined procedure.

Arguments
  • title - the window title

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.

Opens a window with custom options for vsync and AA.

Reference to the scene associated with this window.

Mutable reference to the scene associated with this window.

Read the pixels currently displayed to the screen.

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

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

Get the current screen as an image

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

Gets the status of a key.

Gets the last known position of the mouse.

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

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

Render one frame using the specified state.

Renders the scene using the default camera.

Returns false if the window should be closed.

Render using a specific post processing effect.

Returns false if the window should be closed.

Render using a specific camera.

Returns false if the window should be closed.

Render using a specific 2D and 3D camera.

Returns false if the window should be closed.

Render using a specific camera and post processing effect.

Returns false if the window should be closed.

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

Returns false if the window should be closed.

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

Returns false if the window should be closed.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.