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
#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
cfg_if::cfg_if! {
if #[cfg(any(target_os="windows", target_os="macos", target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))] {
use sixtyfps_rendering_backend_qt as default_backend;
} else {
use sixtyfps_rendering_backend_gl as default_backend;
}
}
pub fn backend() -> &'static dyn sixtyfps_corelib::backend::Backend {
sixtyfps_corelib::backend::instance_or_init(|| {
#[cfg(any(
feature = "sixtyfps-rendering-backend-qt",
feature = "sixtyfps-rendering-backend-gl"
))]
let backend_config = std::env::var("SIXTYFPS_BACKEND").unwrap_or_default();
#[cfg(feature = "sixtyfps-rendering-backend-qt")]
if backend_config == "Qt" {
return Box::new(sixtyfps_rendering_backend_qt::Backend);
}
#[cfg(feature = "sixtyfps-rendering-backend-gl")]
if backend_config == "GL" {
return Box::new(sixtyfps_rendering_backend_gl::Backend);
}
#[cfg(any(
feature = "sixtyfps-rendering-backend-qt",
feature = "sixtyfps-rendering-backend-gl"
))]
if !backend_config.is_empty() {
eprintln!("Could not load rendering backend {}, fallback to default", backend_config)
}
#[cfg(feature = "sixtyfps-rendering-backend-gl")]
if !default_backend::IS_AVAILABLE {
return Box::new(sixtyfps_rendering_backend_gl::Backend);
}
Box::new(default_backend::Backend)
})
}
pub use default_backend::{
native_widgets, Backend, NativeGlobals, NativeWidgets, HAS_NATIVE_STYLE,
};
#[doc(hidden)]
#[cold]
#[cfg(not(target_arch = "wasm32"))]
pub fn use_modules() {
sixtyfps_corelib::use_modules();
default_backend::use_modules();
#[cfg(feature = "sixtyfps-rendering-backend-qt")]
sixtyfps_rendering_backend_qt::use_modules();
#[cfg(feature = "sixtyfps-rendering-backend-gl")]
sixtyfps_rendering_backend_gl::use_modules();
}