luminance_windowing/
lib.rs

1//! This crate is deprecated! You must now use the platform crates to customize how a window should be opened.
2
3#![deprecated = "luminance-windowing is not maintained anymore; please directly use the platform crates from now on"]
4#![deny(missing_docs)]
5
6/// Dimension metrics.
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub enum WindowDim {
9  /// Windowed mode.
10  Windowed {
11    /// Width of the window.
12    width: u32,
13    /// Height of the window.
14    height: u32,
15  },
16  /// Fullscreen mode (using the primary monitor resolution, for instance).
17  Fullscreen,
18  /// Fullscreen mode with restricted viewport dimension..
19  FullscreenRestricted {
20    /// Width of the window.
21    width: u32,
22    /// Height of the window.
23    height: u32,
24  },
25}
26
27/// Different window options.
28///
29/// Feel free to look at the different methods available to tweak the options. You may want to start
30/// with `default()`, though.
31#[derive(Clone, Copy, Debug, Eq, PartialEq)]
32pub struct WindowOpt {
33  /// Dimension of the window.
34  pub dim: WindowDim,
35  /// Number of samples for multisampling.
36  ///
37  /// `None` means no multisampling.
38  pub num_samples: Option<u32>,
39}
40
41impl Default for WindowOpt {
42  /// Defaults:
43  ///
44  /// - `dim`: set to WindowDim::Windowed { width: 960, 540 }`.
45  /// - `num_samples` set to `None`.
46  fn default() -> Self {
47    WindowOpt {
48      dim: WindowDim::Windowed {
49        width: 960,
50        height: 540,
51      },
52      num_samples: None,
53    }
54  }
55}
56
57impl WindowOpt {
58  /// Set the dimension of the window.
59  #[inline]
60  pub fn set_dim(self, dim: WindowDim) -> Self {
61    WindowOpt { dim, ..self }
62  }
63
64  /// Get the dimension of the window.
65  #[inline]
66  pub fn dim(&self) -> &WindowDim {
67    &self.dim
68  }
69
70  /// Set the number of samples to use for multisampling.
71  ///
72  /// Pass `None` to disable multisampling.
73  #[inline]
74  pub fn set_num_samples<S>(self, num_samples: S) -> Self
75  where
76    S: Into<Option<u32>>,
77  {
78    WindowOpt {
79      num_samples: num_samples.into(),
80      ..self
81    }
82  }
83
84  /// Get the number of samples to use in multisampling, if any.
85  #[inline]
86  pub fn num_samples(&self) -> &Option<u32> {
87    &self.num_samples
88  }
89}