diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2014-11-14 16:03:36 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2014-11-14 16:03:36 +0100 |
commit | 28227a2142556f72239105f09a010232bd8f97a4 (patch) | |
tree | 52826c150caf1cad30603b26a39b7a5d5a4ea132 /src/x11/headless.rs | |
parent | 1c69819084286b3f62b6995c48a60b8eb3529982 (diff) | |
parent | 9b39d99f6efa45bb6629f9f819c7e8589281e61e (diff) | |
download | glutin-28227a2142556f72239105f09a010232bd8f97a4.tar.gz glutin-28227a2142556f72239105f09a010232bd8f97a4.zip |
Merge pull request #115 from tomaka/detect-osmesa-errors
Detect OSMesa errors
Diffstat (limited to 'src/x11/headless.rs')
-rw-r--r-- | src/x11/headless.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/x11/headless.rs b/src/x11/headless.rs index 71232e5..977305a 100644 --- a/src/x11/headless.rs +++ b/src/x11/headless.rs @@ -1,5 +1,5 @@ use HeadlessRendererBuilder; -use CreationError; +use {CreationError, OsError}; use libc; use std::{mem, ptr}; use super::ffi; @@ -18,16 +18,23 @@ impl HeadlessContext { height: builder.dimensions.1, buffer: Vec::from_elem(builder.dimensions.0 * builder.dimensions.1, unsafe { mem::uninitialized() }), context: unsafe { - // TODO: check errors - ffi::OSMesaCreateContext(0x1908, ptr::null()) + let ctxt = ffi::OSMesaCreateContext(0x1908, ptr::null()); + if ctxt.is_null() { + return Err(OsError("OSMesaCreateContext failed".to_string())); + } + ctxt } }) } pub unsafe fn make_current(&self) { - ffi::OSMesaMakeCurrent(self.context, + let ret = ffi::OSMesaMakeCurrent(self.context, self.buffer.as_ptr() as *mut libc::c_void, 0x1401, self.width as libc::c_int, self.height as libc::c_int); + + if ret == 0 { + panic!("OSMesaMakeCurrent failed") + } } pub fn get_proc_address(&self, addr: &str) -> *const () { |