winit-sonoma-fix/tests/headless.rs

29 lines
827 B
Rust
Raw Normal View History

2014-10-05 04:17:02 +11:00
extern crate glutin;
2014-10-12 05:38:52 +11:00
extern crate libc;
mod gl {
2014-12-24 18:09:16 +11:00
include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
2014-10-12 05:38:52 +11:00
}
2014-10-05 04:17:02 +11:00
#[cfg(feature = "headless")]
#[test]
fn main() {
let window = glutin::HeadlessRendererBuilder::new(1024, 768).build().unwrap();
unsafe { window.make_current() };
2014-10-12 05:38:52 +11:00
let gl = gl::Gl::load_with(|symbol| window.get_proc_address(symbol));
2014-11-06 01:22:21 +11:00
unsafe {
gl.ClearColor(0.0, 1.0, 0.0, 1.0);
gl.Clear(gl::COLOR_BUFFER_BIT);
let mut value: (u8, u8, u8, u8) = std::mem::uninitialized();
gl.ReadPixels(0, 0, 1, 1, gl::RGBA, gl::UNSIGNED_BYTE, std::mem::transmute(&mut value));
assert!(value == (0, 255, 0, 255) || value == (0, 64, 0, 255) ||
2014-11-15 01:59:45 +11:00
value == (0, 64, 0, 255) || value == (0, 64, 0, 0),
2015-01-10 09:06:14 +11:00
"value is: {:?}", value);
2014-11-06 01:22:21 +11:00
}
2014-10-05 04:17:02 +11:00
}