2014-08-04 01:23:08 +10:00
|
|
|
extern crate gl;
|
2014-08-13 21:42:59 +10:00
|
|
|
extern crate gl_init;
|
|
|
|
extern crate libc;
|
2014-08-04 01:23:08 +10:00
|
|
|
|
|
|
|
fn main() {
|
2014-08-13 21:42:59 +10:00
|
|
|
let window1 = gl_init::Window::new().unwrap();
|
|
|
|
let window2 = gl_init::Window::new().unwrap();
|
|
|
|
let window3 = gl_init::Window::new().unwrap();
|
2014-08-04 01:23:08 +10:00
|
|
|
|
|
|
|
spawn(proc() {
|
|
|
|
run(window1, (0.0, 1.0, 0.0, 1.0));
|
|
|
|
});
|
|
|
|
|
|
|
|
spawn(proc() {
|
|
|
|
run(window2, (0.0, 0.0, 1.0, 1.0));
|
|
|
|
});
|
2014-08-08 02:15:09 +10:00
|
|
|
|
|
|
|
spawn(proc() {
|
|
|
|
run(window3, (1.0, 0.0, 0.0, 1.0));
|
|
|
|
});
|
2014-08-04 01:23:08 +10:00
|
|
|
}
|
|
|
|
|
2014-08-13 21:42:59 +10:00
|
|
|
fn run(window: gl_init::Window, color: (f32, f32, f32, f32)) {
|
2014-08-04 01:23:08 +10:00
|
|
|
unsafe { window.make_current() };
|
|
|
|
|
2014-08-11 18:32:33 +10:00
|
|
|
gl::load_with(|symbol| window.get_proc_address(symbol));
|
2014-08-07 17:32:13 +10:00
|
|
|
|
|
|
|
{
|
|
|
|
let win_size = window.get_inner_size().unwrap();
|
|
|
|
gl::Viewport(0, 0, win_size.val0() as libc::c_int, win_size.val1() as libc::c_int);
|
|
|
|
}
|
2014-08-04 01:23:08 +10:00
|
|
|
|
|
|
|
gl::ClearColor(color.val0(), color.val1(), color.val2(), color.val3());
|
|
|
|
|
|
|
|
while !window.is_closed() {
|
|
|
|
gl::Clear(gl::COLOR_BUFFER_BIT);
|
|
|
|
window.swap_buffers();
|
2014-08-07 17:32:13 +10:00
|
|
|
|
2014-08-13 21:42:59 +10:00
|
|
|
window.wait_events().collect::<Vec<gl_init::Event>>();
|
2014-08-04 01:23:08 +10:00
|
|
|
}
|
|
|
|
}
|