aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/wgl/mod.rs
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-07-09 11:06:51 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-07-09 11:06:51 +0200
commita15d42069e6ca2768dc286049fe1a935ff1a649a (patch)
treea72ddc653b498c7cba879f7d38e79b10911ec56c /src/api/wgl/mod.rs
parentd3fd00968e8ef61c9f50e492c5f6a10225a46376 (diff)
parentbbd31608e87facd2fa07b5a6f2ab73f829e6d9fe (diff)
downloadglutin-a15d42069e6ca2768dc286049fe1a935ff1a649a.tar.gz
glutin-a15d42069e6ca2768dc286049fe1a935ff1a649a.zip
Merge pull request #519 from tomaka/win32-err
Better win32 error messages
Diffstat (limited to 'src/api/wgl/mod.rs')
-rw-r--r--src/api/wgl/mod.rs39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/api/wgl/mod.rs b/src/api/wgl/mod.rs
index cf09ad0..222620c 100644
--- a/src/api/wgl/mod.rs
+++ b/src/api/wgl/mod.rs
@@ -216,7 +216,7 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'st
{
let share = share.unwrap_or(ptr::null_mut());
- let ctxt = if let Some((extra_functions, builder, extensions)) = extra {
+ if let Some((extra_functions, builder, extensions)) = extra {
if extensions.split(' ').find(|&i| i == "WGL_ARB_create_context").is_some() {
let mut attributes = Vec::new();
@@ -308,33 +308,32 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'st
attributes.push(0);
- Some(extra_functions.CreateContextAttribsARB(hdc as *const libc::c_void,
- share as *const libc::c_void,
- attributes.as_ptr()))
+ let ctxt = extra_functions.CreateContextAttribsARB(hdc as *const libc::c_void,
+ share as *const libc::c_void,
+ attributes.as_ptr());
- } else {
- None
- }
- } else {
- None
- };
-
- let ctxt = match ctxt {
- Some(ctxt) => ctxt,
- None => {
- let ctxt = gl::wgl::CreateContext(hdc as *const libc::c_void);
- if !ctxt.is_null() && !share.is_null() {
- gl::wgl::ShareLists(share as *const libc::c_void, ctxt);
- };
- ctxt
+ if ctxt.is_null() {
+ return Err(CreationError::OsError(format!("wglCreateContextAttribsARB failed: {}",
+ format!("{}", io::Error::last_os_error()))));
+ } else {
+ return Ok(ContextWrapper(ctxt as winapi::HGLRC));
+ }
}
};
+ let ctxt = gl::wgl::CreateContext(hdc as *const libc::c_void);
if ctxt.is_null() {
- return Err(CreationError::OsError(format!("OpenGL context creation failed: {}",
+ return Err(CreationError::OsError(format!("wglCreateContext failed: {}",
format!("{}", io::Error::last_os_error()))));
}
+ if !share.is_null() {
+ if gl::wgl::ShareLists(share as *const libc::c_void, ctxt) == 0 {
+ return Err(CreationError::OsError(format!("wglShareLists failed: {}",
+ format!("{}", io::Error::last_os_error()))));
+ }
+ };
+
Ok(ContextWrapper(ctxt as winapi::HGLRC))
}