aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-03-28 20:40:46 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-03-28 20:40:46 +0100
commit9ce644618b719802cc113713abc63b0f0cba1c6c (patch)
tree244840b2db447c0ebd9919c36a5d405beac8b68d /src
parent1557cd227fab9adb66bc3e3bf6849ee6174fafd4 (diff)
parent697d42a64f89e7c8e142d6f444eaa2dde3eb421b (diff)
downloadglutin-9ce644618b719802cc113713abc63b0f0cba1c6c.tar.gz
glutin-9ce644618b719802cc113713abc63b0f0cba1c6c.zip
Merge pull request #329 from tomaka/choose-pixel-format
choose_pixel_format now returns a Result
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs4
-rw-r--r--src/win32/init.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 7f404c3..aba6752 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -304,7 +304,7 @@ impl<'a> BuilderAttribs<'a> {
(new_attribs, sharing)
}
- fn choose_pixel_format<T, I>(&self, iter: I) -> (T, PixelFormat)
+ fn choose_pixel_format<T, I>(&self, iter: I) -> Result<(T, PixelFormat), CreationError>
where I: Iterator<Item=(T, PixelFormat)>, T: Clone
{
let mut current_result = None;
@@ -343,7 +343,7 @@ impl<'a> BuilderAttribs<'a> {
}
current_result.or(current_software_result)
- .expect("Could not find compliant pixel format")
+ .ok_or(CreationError::NotSupported)
}
}
diff --git a/src/win32/init.rs b/src/win32/init.rs
index 5266ae4..08d54c0 100644
--- a/src/win32/init.rs
+++ b/src/win32/init.rs
@@ -136,7 +136,7 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
// getting the pixel format that we will use and setting it
{
let formats = enumerate_native_pixel_formats(&dummy_window);
- let (id, _) = builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a)));
+ let (id, _) = try!(builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a))));
try!(set_pixel_format(&dummy_window, id));
}
@@ -206,7 +206,7 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
enumerate_native_pixel_formats(&real_window)
};
- let (id, _) = builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a)));
+ let (id, _) = try!(builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a))));
try!(set_pixel_format(&real_window, id));
}