mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
commit
04a651320b
|
@ -335,7 +335,7 @@ impl Window {
|
||||||
|
|
||||||
match builder.gl_robustness {
|
match builder.gl_robustness {
|
||||||
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::RobustnessNotSupported);
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
@ -512,11 +512,11 @@ impl Window {
|
||||||
},
|
},
|
||||||
(_, Some((1 ... 2, _)), Some(GlProfile::Core)) |
|
(_, Some((1 ... 2, _)), Some(GlProfile::Core)) |
|
||||||
(_, Some((3 ... 4, _)), Some(GlProfile::Compatibility)) =>
|
(_, Some((3 ... 4, _)), Some(GlProfile::Compatibility)) =>
|
||||||
return Err(CreationError::NotSupported),
|
return Err(CreationError::OpenGlVersionNotSupported),
|
||||||
(_, Some((1 ... 2, _)), _) => NSOpenGLProfileVersionLegacy as u32,
|
(_, Some((1 ... 2, _)), _) => NSOpenGLProfileVersionLegacy as u32,
|
||||||
(_, Some((3, 0 ... 2)), _) => NSOpenGLProfileVersion3_2Core as u32,
|
(_, Some((3, 0 ... 2)), _) => NSOpenGLProfileVersion3_2Core as u32,
|
||||||
(_, Some((3 ... 4, _)), _) => NSOpenGLProfileVersion4_1Core as u32,
|
(_, Some((3 ... 4, _)), _) => NSOpenGLProfileVersion4_1Core as u32,
|
||||||
_ => return Err(CreationError::NotSupported),
|
_ => return Err(CreationError::OpenGlVersionNotSupported),
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: OS X no longer has the concept of setting individual
|
// NOTE: OS X no longer has the concept of setting individual
|
||||||
|
@ -603,7 +603,7 @@ impl Window {
|
||||||
Err(CreationError::NotSupported)
|
Err(CreationError::NotSupported)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(CreationError::NotSupported)
|
Err(CreationError::NoAvailablePixelFormat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ impl Context {
|
||||||
} else if egl.BindAPI(ffi::egl::OPENGL_ES_API) != 0 {
|
} else if egl.BindAPI(ffi::egl::OPENGL_ES_API) != 0 {
|
||||||
(None, Api::OpenGlEs)
|
(None, Api::OpenGlEs)
|
||||||
} else {
|
} else {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::OpenGlVersionNotSupported);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(None, Api::OpenGlEs)
|
(None, Api::OpenGlEs)
|
||||||
|
@ -77,21 +77,21 @@ impl Context {
|
||||||
GlRequest::Specific(Api::OpenGlEs, version) => {
|
GlRequest::Specific(Api::OpenGlEs, version) => {
|
||||||
if egl_version >= (1, 2) {
|
if egl_version >= (1, 2) {
|
||||||
if egl.BindAPI(ffi::egl::OPENGL_ES_API) == 0 {
|
if egl.BindAPI(ffi::egl::OPENGL_ES_API) == 0 {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::OpenGlVersionNotSupported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Some(version), Api::OpenGlEs)
|
(Some(version), Api::OpenGlEs)
|
||||||
},
|
},
|
||||||
GlRequest::Specific(Api::OpenGl, version) => {
|
GlRequest::Specific(Api::OpenGl, version) => {
|
||||||
if egl_version < (1, 4) {
|
if egl_version < (1, 4) {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::OpenGlVersionNotSupported);
|
||||||
}
|
}
|
||||||
if egl.BindAPI(ffi::egl::OPENGL_API) == 0 {
|
if egl.BindAPI(ffi::egl::OPENGL_API) == 0 {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::OpenGlVersionNotSupported);
|
||||||
}
|
}
|
||||||
(Some(version), Api::OpenGl)
|
(Some(version), Api::OpenGl)
|
||||||
},
|
},
|
||||||
GlRequest::Specific(_, _) => return Err(CreationError::NotSupported),
|
GlRequest::Specific(_, _) => return Err(CreationError::OpenGlVersionNotSupported),
|
||||||
GlRequest::GlThenGles { opengles_version, opengl_version } => {
|
GlRequest::GlThenGles { opengles_version, opengl_version } => {
|
||||||
if egl_version >= (1, 4) {
|
if egl_version >= (1, 4) {
|
||||||
if egl.BindAPI(ffi::egl::OPENGL_API) != 0 {
|
if egl.BindAPI(ffi::egl::OPENGL_API) != 0 {
|
||||||
|
@ -99,7 +99,7 @@ impl Context {
|
||||||
} else if egl.BindAPI(ffi::egl::OPENGL_ES_API) != 0 {
|
} else if egl.BindAPI(ffi::egl::OPENGL_ES_API) != 0 {
|
||||||
(Some(opengles_version), Api::OpenGlEs)
|
(Some(opengles_version), Api::OpenGlEs)
|
||||||
} else {
|
} else {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::OpenGlVersionNotSupported);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(Some(opengles_version), Api::OpenGlEs)
|
(Some(opengles_version), Api::OpenGlEs)
|
||||||
|
@ -245,7 +245,7 @@ impl<'a> ContextPrototype<'a> {
|
||||||
{
|
{
|
||||||
ctxt
|
ctxt
|
||||||
} else {
|
} else {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::OpenGlVersionNotSupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -267,7 +267,7 @@ impl<'a> ContextPrototype<'a> {
|
||||||
{
|
{
|
||||||
ctxt
|
ctxt
|
||||||
} else {
|
} else {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::OpenGlVersionNotSupported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -434,7 +434,7 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
|
||||||
context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as libc::c_int);
|
context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as libc::c_int);
|
||||||
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
||||||
} else {
|
} else {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::RobustnessNotSupported);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
|
||||||
context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as libc::c_int);
|
context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as libc::c_int);
|
||||||
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
||||||
} else {
|
} else {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::RobustnessNotSupported);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
|
||||||
// robustness is not supported
|
// robustness is not supported
|
||||||
match gl_robustness {
|
match gl_robustness {
|
||||||
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::RobustnessNotSupported);
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
|
||||||
|
|
||||||
if context.is_null() {
|
if context.is_null() {
|
||||||
match egl.GetError() as u32 {
|
match egl.GetError() as u32 {
|
||||||
ffi::egl::BAD_ATTRIBUTE => return Err(CreationError::NotSupported),
|
ffi::egl::BAD_ATTRIBUTE => return Err(CreationError::OpenGlVersionNotSupported),
|
||||||
e => panic!("eglCreateContext failed: 0x{:x}", e),
|
e => panic!("eglCreateContext failed: 0x{:x}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ fn create_context(glx: &ffi::glx::Glx, extra_functions: &ffi::glx_extra::Glx, ex
|
||||||
} else {
|
} else {
|
||||||
match robustness {
|
match robustness {
|
||||||
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::RobustnessNotSupported);
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,7 @@ fn create_context(glx: &ffi::glx::Glx, extra_functions: &ffi::glx_extra::Glx, ex
|
||||||
};
|
};
|
||||||
|
|
||||||
if context.is_null() {
|
if context.is_null() {
|
||||||
|
// TODO: check for errors and return `OpenGlVersionNotSupported`
|
||||||
return Err(CreationError::OsError(format!("GL context creation failed")));
|
return Err(CreationError::OsError(format!("GL context creation failed")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,13 @@ impl OsMesaContext {
|
||||||
|
|
||||||
match builder.gl_robustness {
|
match builder.gl_robustness {
|
||||||
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
||||||
return Err(CreationError::NotSupported.into());
|
return Err(CreationError::RobustnessNotSupported.into());
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: check OpenGL version and return `OpenGlVersionNotSupported` if necessary
|
||||||
|
|
||||||
Ok(OsMesaContext {
|
Ok(OsMesaContext {
|
||||||
width: dimensions.0,
|
width: dimensions.0,
|
||||||
height: dimensions.1,
|
height: dimensions.1,
|
||||||
|
|
|
@ -235,7 +235,7 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'st
|
||||||
attributes.push(gl::wgl_extra::CONTEXT_PROFILE_MASK_ARB as libc::c_int);
|
attributes.push(gl::wgl_extra::CONTEXT_PROFILE_MASK_ARB as libc::c_int);
|
||||||
attributes.push(gl::wgl_extra::CONTEXT_ES2_PROFILE_BIT_EXT as libc::c_int);
|
attributes.push(gl::wgl_extra::CONTEXT_ES2_PROFILE_BIT_EXT as libc::c_int);
|
||||||
} else {
|
} else {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::OpenGlVersionNotSupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
|
attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
|
||||||
|
@ -243,7 +243,7 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'st
|
||||||
attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int);
|
attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int);
|
||||||
attributes.push(minor as libc::c_int);
|
attributes.push(minor as libc::c_int);
|
||||||
},
|
},
|
||||||
GlRequest::Specific(_, _) => return Err(CreationError::NotSupported),
|
GlRequest::Specific(_, _) => return Err(CreationError::OpenGlVersionNotSupported),
|
||||||
GlRequest::GlThenGles { opengl_version: (major, minor), .. } => {
|
GlRequest::GlThenGles { opengl_version: (major, minor), .. } => {
|
||||||
attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
|
attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
|
||||||
attributes.push(major as libc::c_int);
|
attributes.push(major as libc::c_int);
|
||||||
|
@ -290,7 +290,7 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'st
|
||||||
} else {
|
} else {
|
||||||
match builder.gl_robustness {
|
match builder.gl_robustness {
|
||||||
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::RobustnessNotSupported);
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
@ -573,5 +573,5 @@ fn choose_dummy_pixel_format<I>(iter: I) -> Result<libc::c_int, CreationError>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_id.ok_or(CreationError::NotSupported)
|
backup_id.ok_or(CreationError::OsError("No available pixel format".to_string()))
|
||||||
}
|
}
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -108,7 +108,11 @@ pub trait GlContext {
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum CreationError {
|
pub enum CreationError {
|
||||||
OsError(String),
|
OsError(String),
|
||||||
|
/// TODO: remove this error
|
||||||
NotSupported,
|
NotSupported,
|
||||||
|
RobustnessNotSupported,
|
||||||
|
OpenGlVersionNotSupported,
|
||||||
|
NoAvailablePixelFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreationError {
|
impl CreationError {
|
||||||
|
@ -116,6 +120,12 @@ impl CreationError {
|
||||||
match *self {
|
match *self {
|
||||||
CreationError::OsError(ref text) => &text,
|
CreationError::OsError(ref text) => &text,
|
||||||
CreationError::NotSupported => "Some of the requested attributes are not supported",
|
CreationError::NotSupported => "Some of the requested attributes are not supported",
|
||||||
|
CreationError::RobustnessNotSupported => "Your requested robustness, but it is \
|
||||||
|
not supported.",
|
||||||
|
CreationError::OpenGlVersionNotSupported => "The requested OpenGL version is not \
|
||||||
|
supported.",
|
||||||
|
CreationError::NoAvailablePixelFormat => "Couldn't find any pixel format that matches \
|
||||||
|
the criterias.",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,7 +475,7 @@ impl<'a> BuilderAttribs<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
current_result.or(current_software_result)
|
current_result.or(current_software_result)
|
||||||
.ok_or(CreationError::NotSupported)
|
.ok_or(CreationError::NoAvailablePixelFormat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue