create_gpu_driver

Function create_gpu_driver 

Source
pub fn create_gpu_driver<F>(
    facade: &F,
) -> Result<(GliumGpuDriverSender, GliumGpuDriverReceiver), GliumGpuDriverError>
where F: Facade + ?Sized,
Available on crate feature glium only.
Expand description

Creates a GPU driver for glium.

glium context must run in one thread, but the gpu_driver require Send, since it works by creating multiple callbacks to ultralight C library.

We cannot guarantee that ultralight callbacks will be called in the same thread as glium, and thus, we create two objects. One is the sender, which implements GpuDriver, and should be used by the ultralight library. And the other is the receiver, which handles all gpu rendering logic.

Make sure that both the sender and the receiver are alive for the whole lifetime of the Renderer

§Examples

let (sender, mut receiver) = create_gpu_driver(&display);
platform::set_gpu_driver(lib.clone(), sender);

renderer.render(); // will dispatch and send all events to `reciever` from `ultralight`
receiver.render(); // will render all events received from `sender`