Provide a little more fleshed out and working example
This commit is contained in:
parent
f890b4011d
commit
ca5076a453
|
@ -1,6 +1,9 @@
|
||||||
extern crate wayland_server;
|
extern crate wayland_server;
|
||||||
extern crate smithay;
|
extern crate smithay;
|
||||||
|
extern crate glium;
|
||||||
|
|
||||||
|
use glium::Surface;
|
||||||
|
use smithay::backend::graphics::glium::IntoGlium;
|
||||||
use smithay::backend::input::InputBackend;
|
use smithay::backend::input::InputBackend;
|
||||||
use smithay::backend::winit;
|
use smithay::backend::winit;
|
||||||
use smithay::shm::ShmGlobal;
|
use smithay::shm::ShmGlobal;
|
||||||
|
@ -8,15 +11,13 @@ use wayland_server::protocol::wl_shm;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Initialize a simple backend for testing
|
// Initialize a simple backend for testing
|
||||||
let (mut renderer, mut input) = winit::init().unwrap();
|
let (renderer, mut input) = winit::init().unwrap();
|
||||||
|
|
||||||
let (_, mut event_loop) = wayland_server::create_display();
|
let (_display, mut event_loop) = wayland_server::create_display();
|
||||||
|
|
||||||
// Insert the ShmGlobal as a handler to your event loop
|
// Insert the ShmGlobal as a handler to your event loop
|
||||||
// Here, we specify tha the standard Argb8888 and Xrgb8888 is the only supported.
|
// Here, we specify tha the standard Argb8888 and Xrgb8888 is the only supported.
|
||||||
let handler_id =
|
let handler_id = event_loop.add_handler_with_init(ShmGlobal::new(vec![], None /* we don't provide a logger here */));
|
||||||
event_loop.add_handler_with_init(ShmGlobal::new(vec![],
|
|
||||||
None /* we don't provide a logger here */));
|
|
||||||
|
|
||||||
// Register this handler to advertise a wl_shm global of version 1
|
// Register this handler to advertise a wl_shm global of version 1
|
||||||
let shm_global = event_loop.register_global::<wl_shm::WlShm, ShmGlobal>(handler_id, 1);
|
let shm_global = event_loop.register_global::<wl_shm::WlShm, ShmGlobal>(handler_id, 1);
|
||||||
|
@ -27,10 +28,17 @@ fn main() {
|
||||||
state.get_handler::<ShmGlobal>(handler_id).get_token()
|
state.get_handler::<ShmGlobal>(handler_id).get_token()
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO render stuff
|
// Init glium
|
||||||
|
let context = renderer.into_glium();
|
||||||
|
|
||||||
// TODO put input handling on the event loop
|
|
||||||
|
loop {
|
||||||
input.dispatch_new_events().unwrap();
|
input.dispatch_new_events().unwrap();
|
||||||
|
|
||||||
event_loop.run().unwrap();
|
let mut frame = context.draw();
|
||||||
|
frame.clear(None, Some((0.0, 0.0, 0.0, 1.0)), false, None, None);
|
||||||
|
frame.finish().unwrap();
|
||||||
|
|
||||||
|
event_loop.dispatch(Some(16)).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue