mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-29 13:24:48 +00:00
Run the C++ generated component through the GL backend
... which in turn forward to the corelib, but with the GL renderer attached.
This commit is contained in:
parent
5b4966f652
commit
83eb00b080
6 changed files with 87 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
use core::ptr::NonNull;
|
||||
|
||||
pub mod graphics;
|
||||
|
||||
pub mod abi {
|
||||
|
@ -57,6 +59,31 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn run_component<GraphicsBackend, GraphicsFactoryFunc>(
|
||||
component_type: *const abi::datastructures::ComponentType,
|
||||
component: NonNull<abi::datastructures::ComponentImpl>,
|
||||
graphics_backend_factory: GraphicsFactoryFunc,
|
||||
) where
|
||||
GraphicsBackend: graphics::GraphicsBackend + 'static,
|
||||
GraphicsFactoryFunc:
|
||||
FnOnce(&winit::event_loop::EventLoop<()>, winit::window::WindowBuilder) -> GraphicsBackend,
|
||||
{
|
||||
let component = unsafe {
|
||||
abi::datastructures::ComponentUniquePtr::new(
|
||||
NonNull::new_unchecked(component_type as *mut _),
|
||||
component,
|
||||
)
|
||||
};
|
||||
|
||||
let main_window = MainWindow::new(graphics_backend_factory);
|
||||
|
||||
main_window.run_event_loop(move |_width, _height, mut _renderer| {
|
||||
component.visit_items(|item| {
|
||||
println!("Rendering... {:?}", item.rendering_info());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue