mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Extract load_opengl32_dll
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user