2020-05-28 01:46:17 +02:00
|
|
|
//! Configure a renderer.
|
2023-08-30 04:31:21 +02:00
|
|
|
use crate::core::{Font, Pixels};
|
2024-03-22 07:09:51 +01:00
|
|
|
use crate::graphics::{self, Antialiasing};
|
2023-02-04 07:33:33 +01:00
|
|
|
|
2024-04-03 23:39:38 +02:00
|
|
|
/// The settings of a [`Renderer`].
|
2020-01-09 18:31:07 +01:00
|
|
|
///
|
2024-04-03 23:39:38 +02:00
|
|
|
/// [`Renderer`]: crate::Renderer
|
2023-02-04 07:33:33 +01:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2020-01-01 17:49:48 +01:00
|
|
|
pub struct Settings {
|
2024-04-03 23:39:38 +02:00
|
|
|
/// The present mode of the [`Renderer`].
|
2020-11-23 00:00:13 +01:00
|
|
|
///
|
2024-04-03 23:39:38 +02:00
|
|
|
/// [`Renderer`]: crate::Renderer
|
2020-11-23 00:00:13 +01:00
|
|
|
pub present_mode: wgpu::PresentMode,
|
|
|
|
|
|
2024-04-03 23:39:38 +02:00
|
|
|
/// The graphics backends to use.
|
|
|
|
|
pub backends: wgpu::Backends,
|
2021-03-25 11:27:31 +01:00
|
|
|
|
2023-02-04 07:33:33 +01:00
|
|
|
/// The default [`Font`] to use.
|
|
|
|
|
pub default_font: Font,
|
2020-02-15 10:08:27 +01:00
|
|
|
|
2020-06-19 00:08:28 +02:00
|
|
|
/// The default size of text.
|
|
|
|
|
///
|
2023-02-04 16:41:18 +01:00
|
|
|
/// By default, it will be set to `16.0`.
|
2023-08-30 04:31:21 +02:00
|
|
|
pub default_text_size: Pixels,
|
2020-06-19 00:08:28 +02:00
|
|
|
|
2020-02-15 10:08:27 +01:00
|
|
|
/// The antialiasing strategy that will be used for triangle primitives.
|
2021-07-22 18:27:33 +07:00
|
|
|
///
|
|
|
|
|
/// By default, it is `None`.
|
2020-02-18 08:48:54 +01:00
|
|
|
pub antialiasing: Option<Antialiasing>,
|
2020-02-15 10:08:27 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-24 20:08:40 +01:00
|
|
|
impl Default for Settings {
|
|
|
|
|
fn default() -> Settings {
|
|
|
|
|
Settings {
|
2022-07-02 15:39:42 +08:00
|
|
|
present_mode: wgpu::PresentMode::AutoVsync,
|
2024-04-03 23:39:38 +02:00
|
|
|
backends: wgpu::Backends::all(),
|
2023-03-30 00:56:00 +02:00
|
|
|
default_font: Font::default(),
|
2023-08-30 04:31:21 +02:00
|
|
|
default_text_size: Pixels(16.0),
|
2020-02-24 20:08:40 +01:00
|
|
|
antialiasing: None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-22 07:09:51 +01:00
|
|
|
|
|
|
|
|
impl From<graphics::Settings> for Settings {
|
|
|
|
|
fn from(settings: graphics::Settings) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
default_font: settings.default_font,
|
|
|
|
|
default_text_size: settings.default_text_size,
|
|
|
|
|
antialiasing: settings.antialiasing,
|
|
|
|
|
..Settings::default()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|