winit-sonoma-fix/tests/headless.rs

36 lines
911 B
Rust
Raw Normal View History

2014-10-05 04:17:02 +11:00
#![feature(phase)]
#![feature(tuple_indexing)]
2014-10-12 05:38:52 +11:00
#[phase(plugin)]
extern crate gl_generator;
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-10-22 17:04:13 +11:00
generate_gl_bindings! {
api: "gl",
profile: "core",
version: "1.1",
generator: "struct"
}
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));
gl.ClearColor(0.0, 1.0, 0.0, 1.0);
gl.Clear(gl::COLOR_BUFFER_BIT);
let mut value: (u8, u8, u8, u8) = unsafe { std::mem::uninitialized() };
unsafe { gl.ReadPixels(0, 0, 1, 1, gl::RGBA, gl::UNSIGNED_BYTE, std::mem::transmute(&mut value)) };
2014-10-27 01:58:43 +11:00
assert!(value == (0, 255, 0, 255) || value == (0, 64, 0, 255) ||
value == (0, 64, 0, 255) || value == (0, 64, 0, 0));
2014-10-05 04:17:02 +11:00
}