|
2 | 2 | //! |
3 | 3 | //! # Building a window |
4 | 4 | //! |
5 | | -//! Before you can build a window, you first need to build an `EventLoop`. This is done with the |
6 | | -//! `EventLoop::new()` function. Example: |
| 5 | +//! Before you can build a [`Window`], you first need to build an [`EventLoop`]. This is done with the |
| 6 | +//! [`EventLoop::new()`] function. |
7 | 7 | //! |
8 | 8 | //! ```no_run |
9 | 9 | //! use winit::event_loop::EventLoop; |
10 | 10 | //! let events_loop = EventLoop::new(); |
11 | 11 | //! ``` |
12 | 12 | //! |
13 | | -//! Once this is done there are two ways to create a window: |
| 13 | +//! Once this is done there are two ways to create a [`Window`]: |
14 | 14 | //! |
15 | | -//! - Calling `Window::new(&events_loop)`. |
16 | | -//! - Calling `let builder = WindowBuilder::new()` then `builder.build(&events_loop)`. |
| 15 | +//! - Calling [`Window::new(&events_loop)`][window_new]. |
| 16 | +//! - Calling [`let builder = WindowBuilder::new()`][window_builder_new] then [`builder.build(&events_loop)`][window_builder_build]. |
17 | 17 | //! |
18 | 18 | //! The first way is the simplest way and will give you default values for everything. |
19 | 19 | //! |
20 | | -//! The second way allows you to customize the way your window will look and behave by modifying |
21 | | -//! the fields of the `WindowBuilder` object before you create the window. |
| 20 | +//! The second way allows you to customize the way your [`Window`] will look and behave by modifying |
| 21 | +//! the fields of the [`WindowBuilder`] object before you create the [`Window`]. |
22 | 22 | //! |
23 | | -//! # Events handling |
| 23 | +//! # Event handling |
24 | 24 | //! |
25 | | -//! Once a window has been created, it will *generate events*. For example whenever the user moves |
26 | | -//! the window, resizes the window, moves the mouse, etc. an event is generated. |
| 25 | +//! Once a [`Window`] has been created, it will *generate events*. For example whenever the user moves |
| 26 | +//! the [`Window`], resizes the [`Window`], moves the mouse, etc. an event is generated. |
27 | 27 | //! |
28 | | -//! The events generated by a window can be retreived from the `EventLoop` the window was created |
| 28 | +//! The events generated by a [`Window`] can be retreived from the [`EventLoop`] the [`Window`] was created |
29 | 29 | //! with. |
30 | 30 | //! |
31 | | -//! You do this by calling `events_loop.run(...)`. This function will run forever unless it is |
32 | | -//! stopped by returning `ControlFlow::Exit`, at which point the entire program will terminate. |
| 31 | +//! You do this by calling [`events_loop.run(...)`][event_loop_run]. This function will run forever |
| 32 | +//! unless `control_flow` is set to [`ControlFlow`]`::`[`Exit`], at which point [`Event`]`::`[`LoopDestroyed`] |
| 33 | +//! is emitted and the entire program terminates. |
33 | 34 | //! |
34 | 35 | //! ```no_run |
35 | 36 | //! use winit::event_loop::ControlFlow; |
|
48 | 49 | //! }); |
49 | 50 | //! ``` |
50 | 51 | //! |
51 | | -//! If you use multiple windows, the `WindowEvent` event has a member named `window_id`. You can |
52 | | -//! compare it with the value returned by the `id()` method of `Window` in order to know which |
53 | | -//! window has received the event. |
| 52 | +//! If you use multiple [`Window`]s, [`Event`]`::`[`WindowEvent`] has a member named `window_id`. You can |
| 53 | +//! compare it with the value returned by the [`id()`][window_id_fn] method of [`Window`] in order to know which |
| 54 | +//! [`Window`] has received the event. |
54 | 55 | //! |
55 | 56 | //! # Drawing on the window |
56 | 57 | //! |
57 | | -//! Winit doesn't provide any function that allows drawing on a window. However it allows you to |
58 | | -//! retrieve the raw handle of the window (see the `platform` module for that), which in turn allows you |
59 | | -//! to create an OpenGL/Vulkan/DirectX/Metal/etc. context that will draw on the window. |
60 | | -//! |
| 58 | +//! Winit doesn't provide any function that allows drawing on a [`Window`]. However it allows you to |
| 59 | +//! retrieve the raw handle of the window (see the [`platform`] module), which in turn allows you |
| 60 | +//! to create an OpenGL/Vulkan/DirectX/Metal/etc. context that will draw on the [`Window`]. |
| 61 | +//! |
| 62 | +//! [`EventLoop`]: ./event_loop/struct.EventLoop.html |
| 63 | +//! [`EventLoop::new()`]: ./event_loop/struct.EventLoop.html#method.new |
| 64 | +//! [event_loop_run]: ./event_loop/struct.EventLoop.html#method.run |
| 65 | +//! [`ControlFlow`]: ./event_loop/enum.ControlFlow.html |
| 66 | +//! [`Exit`]: ./event_loop/enum.ControlFlow.html#variant.Exit |
| 67 | +//! [`Window`]: ./window/struct.Window.html |
| 68 | +//! [`WindowBuilder`]: ./window/struct.WindowBuilder.html |
| 69 | +//! [window_new]: ./window/struct.Window.html#method.new |
| 70 | +//! [window_builder_new]: ./window/struct.WindowBuilder.html#method.new |
| 71 | +//! [window_builder_build]: ./window/struct.WindowBuilder.html#method.build |
| 72 | +//! [window_id_fn]: ./window/struct.Window.html#method.id |
| 73 | +//! [`Event`]: ./event/enum.Event.html |
| 74 | +//! [`WindowEvent`]: ./event/enum.Event.html#variant.WindowEvent |
| 75 | +//! [`LoopDestroyed`]: ./event/enum.Event.html#variant.LoopDestroyed |
| 76 | +//! [`platform`]: ./platform/index.html |
61 | 77 |
|
62 | 78 | #[allow(unused_imports)] |
63 | 79 | #[macro_use] |
|
0 commit comments