diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-02-16 15:57:17 +0100 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-02-16 15:59:06 +0100 |
commit | 1a33c9ce9fa5f932d71e2eadf5b7f4ac29b187ee (patch) | |
tree | a37ce4e4cdf89a27f3688e367cf2f2dad4597586 /src/win32/init.rs | |
parent | 950fd58b77041f4c2e62be1e345df8554a447623 (diff) | |
download | glutin-1a33c9ce9fa5f932d71e2eadf5b7f4ac29b187ee.tar.gz glutin-1a33c9ce9fa5f932d71e2eadf5b7f4ac29b187ee.zip |
Extract load_opengl32_dll
Diffstat (limited to 'src/win32/init.rs')
-rw-r--r-- | src/win32/init.rs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/win32/init.rs b/src/win32/init.rs index 9803e43..90a6035 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -258,19 +258,7 @@ fn init(title: Vec<u16>, builder: BuilderAttribs<'static>, builder_sharelists: O }; // loading the opengl32 module - let gl_library = { - let name = "opengl32.dll".utf16_units().chain(Some(0).into_iter()) - .collect::<Vec<u16>>().as_ptr(); - let lib = unsafe { kernel32::LoadLibraryW(name) }; - if lib.is_null() { - let err = Err(OsError(format!("LoadLibrary function failed: {}", - os::error_string(os::errno() as usize)))); - unsafe { gl::wgl::DeleteContext(context as *const libc::c_void); } - unsafe { user32::DestroyWindow(real_window); } - return err; - } - lib - }; + let gl_library = try!(load_opengl32_dll()); // handling vsync if builder.vsync { @@ -511,3 +499,17 @@ fn enumerate_arb_pixel_formats(extra: &gl::wgl_extra::Wgl, hdc: winapi::HDC) result } + +fn load_opengl32_dll() -> Result<winapi::HMODULE, CreationError> { + let name = "opengl32.dll".utf16_units().chain(Some(0).into_iter()) + .collect::<Vec<u16>>().as_ptr(); + + let lib = unsafe { kernel32::LoadLibraryW(name) }; + + if lib.is_null() { + return Err(OsError(format!("LoadLibrary function failed: {}", + os::error_string(os::errno() as usize)))); + } + + Ok(lib) +} |