1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use miniquad::conf::{LinuxBackend, LinuxX11Gl, Platform};
use std::path::PathBuf;
/// Holds configuration values setting different options when starting the game, some of which
/// can't be changed later.
#[derive(Debug)]
pub struct Conf {
/// `Filesystem::open` will try to read from this dir if there's no such file in the cache.
///
/// Note that this won't work on platforms where `std::fs` is unavailable, like WASM.
pub physical_root_dir: Option<PathBuf>,
pub(crate) cache: Option<&'static [u8]>,
pub(crate) quad_conf: miniquad::conf::Conf,
}
impl Default for Conf {
fn default() -> Conf {
Conf {
physical_root_dir: None,
cache: None,
quad_conf: miniquad::conf::Conf {
window_title: "An easy, good game".to_string(),
window_width: 800,
window_height: 600,
high_dpi: false,
fullscreen: false,
sample_count: 1,
window_resizable: false,
icon: None,
platform: Platform {
linux_x11_gl: LinuxX11Gl::GLXWithEGLFallback,
linux_backend: LinuxBackend::X11WithWaylandFallback,
swap_interval: None,
framebuffer_alpha: false,
},
},
}
}
}
impl Conf {
/// Set the root of your filesystem.
///
/// Default: `None`
pub fn physical_root_dir(mut self, val: Option<PathBuf>) -> Self {
self.physical_root_dir = val;
self
}
/// Set the cache, holding embedded files for later use.
///
/// Default: `miniquad::conf::Cache::No`
pub fn cache(mut self, val: Option<&'static [u8]>) -> Self {
self.cache = val;
self
}
/// Set the window title
///
/// Default: "An easy, good game"
pub fn window_title(mut self, val: String) -> Self {
self.quad_conf.window_title = val;
self
}
/// Set the window width in logical pixels.
///
/// Note: See [`high_dpi`](#method.high_dpi) for physical width.
///
/// Default: `800`
pub fn window_width(mut self, val: i32) -> Self {
self.quad_conf.window_width = val;
self
}
/// Set the window height in logical pixels.
///
/// Note: See [`high_dpi`](#method.high_dpi) for physical height.
///
/// Default: `600`
pub fn window_height(mut self, val: i32) -> Self {
self.quad_conf.window_height = val;
self
}
/// Sets whether the rendering canvas is full-resolution on HighDPI displays.
/// * If set to `false` the rendering canvas will be created with the logical window size and
/// then scaled when rendering, to account for the difference between logical and physical size.
/// * If set to `true` the rendering canvas will be created with the physical window size, which
/// can differ from the logical window size due to high-dpi scaling, leading to your drawable space
/// possibly having a different size than specified.
///
/// Default: `false`
pub fn high_dpi(mut self, val: bool) -> Self {
self.quad_conf.high_dpi = val;
self
}
/// Set whether to run in fullscreen mode.
///
/// Default: `false`
pub fn fullscreen(mut self, val: bool) -> Self {
self.quad_conf.fullscreen = val;
self
}
/// Set how many samples should be used in MSAA.
///
/// Default: `1`
pub fn sample_count(mut self, val: i32) -> Self {
self.quad_conf.sample_count = val;
self
}
/// Set whether the window should be resizable by the user.
///
/// Default: `false`
pub fn window_resizable(mut self, val: bool) -> Self {
self.quad_conf.window_resizable = val;
self
}
}
impl From<Conf> for miniquad::conf::Conf {
fn from(conf: Conf) -> Self {
conf.quad_conf
}
}