aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2014-12-28 15:53:24 +0100
committerPierre Krieger <pierre.krieger1708@gmail.com>2014-12-31 07:34:26 +0100
commite1b5d9c1039c6e5a2e977bf2d6c9c3806cde046a (patch)
tree0666cd08a0cb0fb29f65d6305740ae4634911001 /src
parentb9710f05a9d1e7fd10536b604074baf748fb5bd7 (diff)
downloadglutin-e1b5d9c1039c6e5a2e977bf2d6c9c3806cde046a.tar.gz
glutin-e1b5d9c1039c6e5a2e977bf2d6c9c3806cde046a.zip
Add `build_strict` function on builders
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs20
1 files changed, 20 insertions, 0 deletions
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<Window, CreationError> {
+ 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<HeadlessContext, CreationError> {
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<HeadlessContext, CreationError> {
+ self.attribs.strict = true;
+ self.build()
+ }
}
/// Represents an OpenGL context and the Window or environment around it.