By default, enable the GL backend also on desktop

So it can be chosen with an env variable or if Qt is not available
This commit is contained in:
Olivier Goffart 2021-01-11 13:07:25 +01:00 committed by Simon Hausmann
parent 58904f1858
commit 46dbb1ee9e
4 changed files with 17 additions and 1 deletions

View file

@ -14,6 +14,9 @@ path = "lib.rs"
[features]
x11 = ["sixtyfps-rendering-backend-default/x11"]
wayland = ["sixtyfps-rendering-backend-default/wayland"]
backend-gl = ["sixtyfps-rendering-backend-default/sixtyfps-rendering-backend-gl"]
backend-qt = ["sixtyfps-rendering-backend-default/sixtyfps-rendering-backend-qt"]
default = ["backend-gl", "backend-qt"]
[dependencies]
once_cell = "1.5"

View file

@ -13,7 +13,7 @@ path = "lib.rs"
[dependencies]
sixtyfps-corelib = { version = "=0.0.4", path = "../corelib", features = ["rtti"] }
sixtyfps-rendering-backend-default = { version = "=0.0.4", path = "../../sixtyfps_runtime/rendering_backends/default" }
sixtyfps-rendering-backend-default = { version = "=0.0.4", path = "../../sixtyfps_runtime/rendering_backends/default", features = ["sixtyfps-rendering-backend-gl"] }
vtable = { version = "0.1.1", path="../../helper_crates/vtable" }
sixtyfps-compilerlib = { version = "=0.0.4", path = "../../sixtyfps_compiler" }
lyon = { version = "0.16" }

View file

@ -7,6 +7,13 @@
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
/*!
The purpose of this crate is to select the default backend for [SixtyFPS](https://sixtyfps.io)
The backend can either be a runtime or a build time decision. The runtime decision is decided
by the `SIXTYFPS_BACKEND` environment variable. The built time default depends on the platform.
In order for the crate to be available at runtime, they need to be added as feature
*/
use sixtyfps_corelib::window::ComponentWindow;
@ -42,6 +49,10 @@ pub fn create_window() -> ComponentWindow {
eprintln!("Could not load rendering backend {}, fallback to default", backend_config)
}
#[cfg(feature = "sixtyfps-rendering-backend-qt")]
if sixtyfps_rendering_backend_qt::IS_AVAILABLE {
return sixtyfps_rendering_backend_qt::create_window();
}
default_backend::create_window()
}

View file

@ -84,6 +84,8 @@ pub type NativeWidgets = ();
pub type NativeGlobals = ();
pub const HAS_NATIVE_STYLE: bool = cfg!(not(no_qt));
/// False if the backend was compiled without Qt so it wouldn't do anything
pub const IS_AVAILABLE: bool = cfg!(not(no_qt));
pub fn create_window() -> ComponentWindow {
#[cfg(no_qt)]