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:
Simon Hausmann 2020-05-11 15:05:33 +02:00
parent 5b4966f652
commit 83eb00b080
6 changed files with 87 additions and 2 deletions

View file

@ -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]