From e1b5d9c1039c6e5a2e977bf2d6c9c3806cde046a Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Sun, 28 Dec 2014 15:53:24 +0100 Subject: Add `build_strict` function on builders --- src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 29dcdb4..b3dfdd8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,12 +70,14 @@ pub struct MonitorID(winimpl::MonitorID); #[deriving(Clone, Show, PartialEq, Eq)] pub enum CreationError { OsError(String), + NotSupported, } impl std::error::Error for CreationError { fn description(&self) -> &str { match self { &CreationError::OsError(ref text) => text.as_slice(), + &CreationError::NotSupported => "Some of the requested attributes are not supported", } } } @@ -228,6 +230,15 @@ impl<'a> WindowBuilder<'a> { // building winimpl::Window::new(self.attribs).map(|w| Window { window: w }) } + + /// Builds the window. + /// + /// The context is build in a *strict* way. That means that if the backend couldn't give + /// you what you requested, an `Err` will be returned. + pub fn build_strict(mut self) -> Result { + self.attribs.strict = true; + self.build() + } } /// Object that allows you to build headless contexts. @@ -274,6 +285,15 @@ impl HeadlessRendererBuilder { pub fn build(self) -> Result { winimpl::HeadlessContext::new(self.attribs).map(|w| HeadlessContext { context: w }) } + + /// Builds the headless context. + /// + /// The context is build in a *strict* way. That means that if the backend couldn't give + /// you what you requested, an `Err` will be returned. + pub fn build_strict(mut self) -> Result { + self.attribs.strict = true; + self.build() + } } /// Represents an OpenGL context and the Window or environment around it. -- cgit v1.2.3