diff options
| author | tomaka <pierre.krieger1708@gmail.com> | 2015-07-21 17:49:52 +0200 | 
|---|---|---|
| committer | tomaka <pierre.krieger1708@gmail.com> | 2015-07-21 17:49:52 +0200 | 
| commit | 04a651320ba00571a0b2af9ae25c6d6c696c2803 (patch) | |
| tree | 7ba2cf8fbc9ebd9acb1f7854ee4bfef7a5028a44 /src/api | |
| parent | ca1eb8dc533301060e2b2768646b15d79c8be60c (diff) | |
| parent | 7fe828bed3c1e01c0868d83eada0f2f36209c989 (diff) | |
| download | glutin-04a651320ba00571a0b2af9ae25c6d6c696c2803.tar.gz glutin-04a651320ba00571a0b2af9ae25c6d6c696c2803.zip | |
Merge pull request #532 from tomaka/precise-errors
Precise errors
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/cocoa/mod.rs | 8 | ||||
| -rw-r--r-- | src/api/egl/mod.rs | 24 | ||||
| -rw-r--r-- | src/api/glx/mod.rs | 3 | ||||
| -rw-r--r-- | src/api/osmesa/mod.rs | 4 | ||||
| -rw-r--r-- | src/api/wgl/mod.rs | 8 | 
5 files changed, 25 insertions, 22 deletions
| diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs index 332244e..5ea57ae 100644 --- a/src/api/cocoa/mod.rs +++ b/src/api/cocoa/mod.rs @@ -335,7 +335,7 @@ impl Window {          match builder.gl_robustness {              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((3 ... 4, _)), Some(GlProfile::Compatibility)) => -                return Err(CreationError::NotSupported), +                return Err(CreationError::OpenGlVersionNotSupported),              (_, Some((1 ... 2, _)), _) => NSOpenGLProfileVersionLegacy as u32,              (_, Some((3, 0 ... 2)), _) => NSOpenGLProfileVersion3_2Core 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 @@ -603,7 +603,7 @@ impl Window {                      Err(CreationError::NotSupported)                  }              } else { -                Err(CreationError::NotSupported) +                Err(CreationError::NoAvailablePixelFormat)              }          }      } diff --git a/src/api/egl/mod.rs b/src/api/egl/mod.rs index d22c009..328a11e 100644 --- a/src/api/egl/mod.rs +++ b/src/api/egl/mod.rs @@ -68,7 +68,7 @@ impl Context {                          } else if egl.BindAPI(ffi::egl::OPENGL_ES_API) != 0 {                              (None, Api::OpenGlEs)                          } else { -                            return Err(CreationError::NotSupported); +                            return Err(CreationError::OpenGlVersionNotSupported);                          }                      } else {                          (None, Api::OpenGlEs) @@ -77,21 +77,21 @@ impl Context {                  GlRequest::Specific(Api::OpenGlEs, version) => {                      if egl_version >= (1, 2) {                          if egl.BindAPI(ffi::egl::OPENGL_ES_API) == 0 { -                            return Err(CreationError::NotSupported); +                            return Err(CreationError::OpenGlVersionNotSupported);                          }                      }                      (Some(version), Api::OpenGlEs)                  },                  GlRequest::Specific(Api::OpenGl, version) => {                      if egl_version < (1, 4) { -                        return Err(CreationError::NotSupported); +                        return Err(CreationError::OpenGlVersionNotSupported);                      }                      if egl.BindAPI(ffi::egl::OPENGL_API) == 0 { -                        return Err(CreationError::NotSupported); +                        return Err(CreationError::OpenGlVersionNotSupported);                      }                      (Some(version), Api::OpenGl)                  }, -                GlRequest::Specific(_, _) => return Err(CreationError::NotSupported), +                GlRequest::Specific(_, _) => return Err(CreationError::OpenGlVersionNotSupported),                  GlRequest::GlThenGles { opengles_version, opengl_version } => {                      if egl_version >= (1, 4) {                          if egl.BindAPI(ffi::egl::OPENGL_API) != 0 { @@ -99,7 +99,7 @@ impl Context {                          } else if egl.BindAPI(ffi::egl::OPENGL_ES_API) != 0 {                              (Some(opengles_version), Api::OpenGlEs)                          } else { -                            return Err(CreationError::NotSupported); +                            return Err(CreationError::OpenGlVersionNotSupported);                          }                      } else {                          (Some(opengles_version), Api::OpenGlEs) @@ -245,7 +245,7 @@ impl<'a> ContextPrototype<'a> {                  {                      ctxt                  } else { -                    return Err(CreationError::NotSupported); +                    return Err(CreationError::OpenGlVersionNotSupported);                  }              } else { @@ -267,7 +267,7 @@ impl<'a> ContextPrototype<'a> {                  {                      ctxt                  } 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);                      flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;                  } 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);                      flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;                  } 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          match gl_robustness {              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() {          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),          }      } diff --git a/src/api/glx/mod.rs b/src/api/glx/mod.rs index e0adde7..65819f8 100644 --- a/src/api/glx/mod.rs +++ b/src/api/glx/mod.rs @@ -301,7 +301,7 @@ fn create_context(glx: &ffi::glx::Glx, extra_functions: &ffi::glx_extra::Glx, ex                  } else {                      match robustness {                          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() { +            // TODO: check for errors and return `OpenGlVersionNotSupported`              return Err(CreationError::OsError(format!("GL context creation failed")));          } diff --git a/src/api/osmesa/mod.rs b/src/api/osmesa/mod.rs index db0a1e7..056e2d1 100644 --- a/src/api/osmesa/mod.rs +++ b/src/api/osmesa/mod.rs @@ -41,11 +41,13 @@ impl OsMesaContext {          match builder.gl_robustness {              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 {              width: dimensions.0,              height: dimensions.1, diff --git a/src/api/wgl/mod.rs b/src/api/wgl/mod.rs index 222620c..89538f1 100644 --- a/src/api/wgl/mod.rs +++ b/src/api/wgl/mod.rs @@ -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_ES2_PROFILE_BIT_EXT as libc::c_int);                      } else { -                        return Err(CreationError::NotSupported); +                        return Err(CreationError::OpenGlVersionNotSupported);                      }                      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(minor as libc::c_int);                  }, -                GlRequest::Specific(_, _) => return Err(CreationError::NotSupported), +                GlRequest::Specific(_, _) => return Err(CreationError::OpenGlVersionNotSupported),                  GlRequest::GlThenGles { opengl_version: (major, minor), .. } => {                      attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB 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 {                      match builder.gl_robustness {                          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()))  } | 
