extern crate libc;
extern crate glutin;
extern crate glium;
use glium::Surface;
use std::rc::Rc;
fn main() {
let window = glutin::WindowBuilder::new().build().unwrap();
let window = Rc::new(window);
struct Backend {
window: Rc<glutin::Window>,
}
unsafe impl glium::backend::Backend for Backend {
fn swap_buffers(&self) {
self.window.swap_buffers();
}
unsafe fn get_proc_address(&self, symbol: &str) -> *const libc::c_void {
self.window.get_proc_address(symbol)
}
fn get_framebuffer_dimensions(&self) -> (u32, u32) {
self.window.get_inner_size().unwrap_or((128, 128))
}
fn is_current(&self) -> bool {
self.window.is_current()
}
unsafe fn make_current(&self) {
self.window.make_current()
}
}
let context = unsafe {
glium::backend::Context::new::<_, ()>(Backend { window: window.clone() }, true)
}.unwrap();
let mut target = glium::Frame::new(context.clone(), context.get_framebuffer_dimensions());
target.clear_color(0.0, 1.0, 0.0, 1.0);
target.finish();
for event in window.wait_events() {
match event {
glutin::Event::Closed => return,
_ => ()
}
}
}