Struct kiss3d::window::Window
[−]
[src]
pub struct Window { /* fields omitted */ }
Structure representing a window and a 3D scene.
This is the main interface with the 3d engine.
Methods
impl Window
[src]
fn should_close(&self) -> bool
Indicates whether this window should be closed.
fn context(&self) -> &Glfw
Access the glfw context.
fn glfw_window(&self) -> &Window
Access the glfw window.
fn glfw_window_mut(&mut self) -> &mut Window
Mutably access the glfw window.
fn width(&self) -> f32
The window width.
fn height(&self) -> f32
The window height.
fn size(&self) -> Vector2<f32>
The size of the window.
fn set_framerate_limit(&mut self, fps: Option<u64>)
Sets the maximum number of frames per second. Cannot be 0. None
means there is no limit.
fn set_title(&mut self, title: &str)
Set window title
fn close(&mut self)
Closes the window.
fn hide(&mut self)
Hides the window, without closing it. Use show
to make it visible again.
fn show(&mut self)
Makes the window visible. Use hide
to hide it.
fn set_background_color(&mut self, r: f32, g: GLfloat, b: f32)
Sets the background color.
fn draw_line(&mut self, a: &Point3<f32>, b: &Point3<f32>, color: &Point3<f32>)
Adds a line to be drawn during the next frame.
fn draw_point(&mut self, pt: &Point3<f32>, color: &Point3<f32>)
Adds a point to be drawn during the next frame.
fn draw_text(&mut self,
text: &str,
pos: &Point2<f32>,
font: &Rc<Font>,
color: &Point3<f32>)
text: &str,
pos: &Point2<f32>,
font: &Rc<Font>,
color: &Point3<f32>)
Adds a string to be drawn during the next frame.
fn remove(&mut self, sn: &mut SceneNode)
Removes an object from the scene.
fn add_group(&mut self) -> SceneNode
Adds a group to the scene.
A group is a node not containing any object.
fn add_obj(&mut self,
path: &Path,
mtl_dir: &Path,
scale: Vector3<f32>)
-> SceneNode
path: &Path,
mtl_dir: &Path,
scale: Vector3<f32>)
-> SceneNode
Adds an obj model to the scene.
Arguments
path
- relative path to the obj file.scale
- scale to apply to the model.
fn add_mesh(&mut self,
mesh: Rc<RefCell<Mesh>>,
scale: Vector3<f32>)
-> SceneNode
mesh: Rc<RefCell<Mesh>>,
scale: Vector3<f32>)
-> SceneNode
Adds an unnamed mesh to the scene.
fn add_trimesh(&mut self,
descr: TriMesh3<f32>,
scale: Vector3<f32>)
-> SceneNode
descr: TriMesh3<f32>,
scale: Vector3<f32>)
-> SceneNode
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.
fn add_geom_with_name(&mut self,
geometry_name: &str,
scale: Vector3<f32>)
-> Option<SceneNode>
geometry_name: &str,
scale: Vector3<f32>)
-> Option<SceneNode>
Creates and adds a new object using the geometry registered as geometry_name
.
fn add_cube(&mut self, wx: GLfloat, wy: GLfloat, wz: GLfloat) -> SceneNode
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 z axiswy
- the cube extent along the y axiswz
- the cube extent along the z axis
fn add_sphere(&mut self, r: GLfloat) -> SceneNode
Adds a sphere to the scene. The sphere is initially centered at (0, 0, 0).
Arguments
r
- the sphere radius
fn add_cone(&mut self, r: GLfloat, h: GLfloat) -> SceneNode
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 heightr
- the cone base radius
fn add_cylinder(&mut self, r: GLfloat, h: GLfloat) -> SceneNode
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 heightr
- the cylinder base radius
fn add_capsule(&mut self, r: GLfloat, h: GLfloat) -> SceneNode
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
h
- the capsule heightr
- the capsule caps radius
fn add_quad(&mut self,
w: f32,
h: f32,
usubdivs: usize,
vsubdivs: usize)
-> SceneNode
w: f32,
h: f32,
usubdivs: usize,
vsubdivs: usize)
-> SceneNode
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 be0
.hsubdivs
- number of vertical subdivisions. This correspond to the number of squares which will be placed vertically on each line. Must not be0
. update.
fn add_quad_with_vertices(&mut self,
vertices: &[Point3<f32>],
nhpoints: usize,
nvpoints: usize)
-> SceneNode
vertices: &[Point3<f32>],
nhpoints: usize,
nvpoints: usize)
-> SceneNode
Adds a double-sided quad with the specified vertices.
fn is_closed(&self) -> bool
Returns whether this window is closed or not.
fn set_light(&mut self, pos: Light)
Sets the light mode. Only one light is supported.
fn new(title: &str) -> Window
fn new_with_size(title: &str, width: u32, height: u32) -> Window
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.
fn scene(&self) -> &SceneNode
Reference to the scene associated with this window.
fn scene_mut(&mut self) -> &mut SceneNode
Mutable reference to the scene associated with this window.
fn snap(&self, out: &mut Vec<u8>)
Read the pixels currently displayed to the screen.
Arguments:
out
- the output buffer. It is automatically resized.
fn snap_rect(&self,
out: &mut Vec<u8>,
x: usize,
y: usize,
width: usize,
height: usize)
out: &mut Vec<u8>,
x: usize,
y: usize,
width: usize,
height: usize)
Read a section of pixels from the screen
Arguments:
out
- the output buffer. It is automatically resizedx, y, width, height
- the rectangle to capture
fn snap_image(&self) -> ImageBuffer<Rgb<u8>, Vec<u8>>
Get the current screen as an image
fn events(&self) -> EventManager
Gets the events manager that gives access to an event iterator.
fn render(&mut self) -> bool
Renders the scene using the default camera.
Returns false
if the window should be closed.
fn render_with_effect(&mut self, effect: &mut PostProcessingEffect) -> bool
Render using a specific post processing effect.
Returns false
if the window should be closed.
fn render_with_camera(&mut self, camera: &mut Camera) -> bool
Render using a specific camera.
Returns false
if the window should be closed.
fn render_with_camera_and_effect(&mut self,
camera: &mut Camera,
effect: &mut PostProcessingEffect)
-> bool
camera: &mut Camera,
effect: &mut PostProcessingEffect)
-> bool
Render using a specific camera and post processing effect.
Returns false
if the window should be closed.
fn render_with(&mut self,
camera: Option<&mut Camera>,
post_processing: Option<&mut PostProcessingEffect>)
-> bool
camera: Option<&mut Camera>,
post_processing: Option<&mut PostProcessingEffect>)
-> bool
Draws the scene with the given camera and post-processing effect.
Returns false
if the window should be closed.