mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
Add build_strict
function on builders
This commit is contained in:
parent
b9710f05a9
commit
e1b5d9c103
20
src/lib.rs
20
src/lib.rs
|
@ -70,12 +70,14 @@ pub struct MonitorID(winimpl::MonitorID);
|
||||||
#[deriving(Clone, Show, PartialEq, Eq)]
|
#[deriving(Clone, Show, PartialEq, Eq)]
|
||||||
pub enum CreationError {
|
pub enum CreationError {
|
||||||
OsError(String),
|
OsError(String),
|
||||||
|
NotSupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for CreationError {
|
impl std::error::Error for CreationError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
&CreationError::OsError(ref text) => text.as_slice(),
|
&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
|
// building
|
||||||
winimpl::Window::new(self.attribs).map(|w| Window { window: w })
|
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.
|
/// Object that allows you to build headless contexts.
|
||||||
|
@ -274,6 +285,15 @@ impl HeadlessRendererBuilder {
|
||||||
pub fn build(self) -> Result<HeadlessContext, CreationError> {
|
pub fn build(self) -> Result<HeadlessContext, CreationError> {
|
||||||
winimpl::HeadlessContext::new(self.attribs).map(|w| HeadlessContext { context: w })
|
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.
|
/// Represents an OpenGL context and the Window or environment around it.
|
||||||
|
|
Loading…
Reference in a new issue