2017-03-07 10:53:57 +00:00
|
|
|
extern crate wayland_server;
|
|
|
|
extern crate smithay;
|
2017-06-02 13:26:50 +00:00
|
|
|
extern crate glium;
|
2017-03-07 10:53:57 +00:00
|
|
|
|
2017-06-02 13:26:50 +00:00
|
|
|
use glium::Surface;
|
|
|
|
use smithay::backend::graphics::glium::IntoGlium;
|
2017-03-19 20:56:10 +00:00
|
|
|
use smithay::backend::input::InputBackend;
|
2017-05-21 20:51:38 +00:00
|
|
|
use smithay::backend::winit;
|
2017-03-20 13:33:27 +00:00
|
|
|
use smithay::shm::ShmGlobal;
|
2017-03-07 10:53:57 +00:00
|
|
|
use wayland_server::protocol::wl_shm;
|
|
|
|
|
|
|
|
fn main() {
|
2017-05-21 20:40:15 +00:00
|
|
|
// Initialize a simple backend for testing
|
2017-06-02 13:26:50 +00:00
|
|
|
let (renderer, mut input) = winit::init().unwrap();
|
2017-05-21 20:40:15 +00:00
|
|
|
|
2017-06-02 13:26:50 +00:00
|
|
|
let (_display, mut event_loop) = wayland_server::create_display();
|
2017-03-07 10:53:57 +00:00
|
|
|
|
|
|
|
// Insert the ShmGlobal as a handler to your event loop
|
|
|
|
// Here, we specify tha the standard Argb8888 and Xrgb8888 is the only supported.
|
2017-06-02 14:21:29 +00:00
|
|
|
let handler_id =
|
|
|
|
event_loop.add_handler_with_init(ShmGlobal::new(vec![],
|
|
|
|
None /* we don't provide a logger here */));
|
2017-03-07 10:53:57 +00:00
|
|
|
|
|
|
|
// Register this handler to advertise a wl_shm global of version 1
|
2017-03-20 13:33:27 +00:00
|
|
|
let shm_global = event_loop.register_global::<wl_shm::WlShm, ShmGlobal>(handler_id, 1);
|
2017-03-07 10:53:57 +00:00
|
|
|
|
|
|
|
// Retrieve the shm token for later use to access the buffers
|
|
|
|
let shm_token = {
|
|
|
|
let state = event_loop.state();
|
|
|
|
state.get_handler::<ShmGlobal>(handler_id).get_token()
|
|
|
|
};
|
|
|
|
|
2017-06-02 13:26:50 +00:00
|
|
|
// Init glium
|
|
|
|
let context = renderer.into_glium();
|
2017-03-07 10:53:57 +00:00
|
|
|
|
|
|
|
|
2017-06-02 13:26:50 +00:00
|
|
|
loop {
|
|
|
|
input.dispatch_new_events().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();
|
|
|
|
}
|
2017-03-07 10:53:57 +00:00
|
|
|
}
|