diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-06-16 10:15:31 +0200 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-06-16 10:44:44 +0200 |
commit | f6c26ec593ba96d89cb3476c815d6f33a915bfdd (patch) | |
tree | cc204a0cdfed5c3431f1e26cc2da10048d8c3474 /src/api/osmesa | |
parent | e48c853b9c7a617bf8ba5f31b5fb2088c90c0ee7 (diff) | |
download | glutin-f6c26ec593ba96d89cb3476c815d6f33a915bfdd.tar.gz glutin-f6c26ec593ba96d89cb3476c815d6f33a915bfdd.zip |
Handle errors from MakeCurrent and SwapBuffers
Diffstat (limited to 'src/api/osmesa')
-rw-r--r-- | src/api/osmesa/mod.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/api/osmesa/mod.rs b/src/api/osmesa/mod.rs index 26808f7..daaba52 100644 --- a/src/api/osmesa/mod.rs +++ b/src/api/osmesa/mod.rs @@ -4,6 +4,7 @@ extern crate osmesa_sys; use Api; use BuilderAttribs; +use ContextError; use CreationError; use GlContext; use PixelFormat; @@ -67,14 +68,18 @@ impl OsMesaContext { } impl GlContext for OsMesaContext { - unsafe fn make_current(&self) { - let ret = osmesa_sys::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); + unsafe fn make_current(&self) -> Result<(), ContextError> { + let ret = osmesa_sys::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); + // an error can only happen in case of invalid parameter, which would indicate a bug + // in glutin if ret == 0 { - panic!("OSMesaMakeCurrent failed") + panic!("OSMesaMakeCurrent failed"); } + + Ok(()) } fn is_current(&self) -> bool { @@ -88,7 +93,8 @@ impl GlContext for OsMesaContext { } } - fn swap_buffers(&self) { + fn swap_buffers(&self) -> Result<(), ContextError> { + Ok(()) } fn get_api(&self) -> Api { |