mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-14 17:58:40 +00:00
Simplify OpenGL examples to use platform builder API to enforce a GL supported renderer
This commit is contained in:
parent
687e4ce95b
commit
df55e5563b
2 changed files with 89 additions and 85 deletions
|
|
@ -398,13 +398,20 @@ impl DemoRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let platform = slint::platform::PlatformBuilder::new()
|
||||||
|
.with_opengl_api(slint::OpenGLAPI::GLES(None))
|
||||||
|
.build()
|
||||||
|
.expect("Unable to create Slint backend with OpenGL ES renderer");
|
||||||
|
slint::platform::set_platform(platform).unwrap();
|
||||||
|
|
||||||
let app = App::new().unwrap();
|
let app = App::new().unwrap();
|
||||||
|
|
||||||
let mut underlay = None;
|
let mut underlay = None;
|
||||||
|
|
||||||
let app_weak = app.as_weak();
|
let app_weak = app.as_weak();
|
||||||
|
|
||||||
if let Err(error) = app.window().set_rendering_notifier(move |state, graphics_api| {
|
app.window()
|
||||||
|
.set_rendering_notifier(move |state, graphics_api| {
|
||||||
// eprintln!("rendering state {:#?}", state);
|
// eprintln!("rendering state {:#?}", state);
|
||||||
|
|
||||||
match state {
|
match state {
|
||||||
|
|
@ -436,13 +443,8 @@ fn main() {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}) {
|
})
|
||||||
match error {
|
.expect("Unable to set rendering notifier");
|
||||||
slint::SetRenderingNotifierError::Unsupported => eprintln!("This example requires the use of the GL backend. Please run with the environment variable SLINT_BACKEND=GL set."),
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
app.run().unwrap();
|
app.run().unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -176,13 +176,20 @@ pub fn main() {
|
||||||
#[cfg(all(debug_assertions, target_arch = "wasm32"))]
|
#[cfg(all(debug_assertions, target_arch = "wasm32"))]
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
|
|
||||||
|
let platform = slint::platform::PlatformBuilder::new()
|
||||||
|
.with_opengl_api(slint::OpenGLAPI::GLES(None))
|
||||||
|
.build()
|
||||||
|
.expect("Unable to create Slint backend with OpenGL ES renderer");
|
||||||
|
slint::platform::set_platform(platform).unwrap();
|
||||||
|
|
||||||
let app = App::new().unwrap();
|
let app = App::new().unwrap();
|
||||||
|
|
||||||
let mut underlay = None;
|
let mut underlay = None;
|
||||||
|
|
||||||
let app_weak = app.as_weak();
|
let app_weak = app.as_weak();
|
||||||
|
|
||||||
if let Err(error) = app.window().set_rendering_notifier(move |state, graphics_api| {
|
app.window()
|
||||||
|
.set_rendering_notifier(move |state, graphics_api| {
|
||||||
// eprintln!("rendering state {:#?}", state);
|
// eprintln!("rendering state {:#?}", state);
|
||||||
|
|
||||||
match state {
|
match state {
|
||||||
|
|
@ -230,13 +237,8 @@ pub fn main() {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}) {
|
})
|
||||||
match error {
|
.expect("Unable to set rendering notifier");
|
||||||
slint::SetRenderingNotifierError::Unsupported => eprintln!("This example requires the use of the GL backend. Please run with the environment variable SLINT_BACKEND=GL set."),
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
app.run().unwrap();
|
app.run().unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue