#![doc(html_logo_url = "https://sixtyfps.io/resources/logo.drawio.svg")]
#![cfg_attr(
not(any(
feature = "sixtyfps-rendering-backend-qt",
feature = "sixtyfps-rendering-backend-gl"
)),
no_std
)]
cfg_if::cfg_if! {
if #[cfg(feature = "sixtyfps-rendering-backend-qt")] {
use sixtyfps_rendering_backend_qt as default_backend;
} else if #[cfg(feature = "sixtyfps-rendering-backend-gl")] {
use sixtyfps_rendering_backend_gl as default_backend;
}
}
cfg_if::cfg_if! {
if #[cfg(any(
feature = "sixtyfps-rendering-backend-qt",
feature = "sixtyfps-rendering-backend-gl"
))] {
pub fn backend() -> &'static dyn sixtyfps_corelib::backend::Backend {
sixtyfps_corelib::backend::instance_or_init(|| {
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,
};
} else {
pub fn backend() -> &'static dyn sixtyfps_corelib::backend::Backend {
sixtyfps_corelib::backend::instance().expect("no default backend configured, the backend must be initialized manually")
}
pub type NativeWidgets = ();
pub type NativeGlobals = ();
pub mod native_widgets {}
pub const HAS_NATIVE_STYLE: bool = false;
}
}
#[doc(hidden)]
#[cold]
#[cfg(not(target_arch = "wasm32"))]
pub fn use_modules() {
sixtyfps_corelib::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();
}