mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Extract load_opengl32_dll
This commit is contained in:
parent
950fd58b77
commit
1a33c9ce9f
|
@ -258,19 +258,7 @@ fn init(title: Vec<u16>, builder: BuilderAttribs<'static>, builder_sharelists: O
|
||||||
};
|
};
|
||||||
|
|
||||||
// loading the opengl32 module
|
// loading the opengl32 module
|
||||||
let gl_library = {
|
let gl_library = try!(load_opengl32_dll());
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
// handling vsync
|
// handling vsync
|
||||||
if builder.vsync {
|
if builder.vsync {
|
||||||
|
@ -511,3 +499,17 @@ fn enumerate_arb_pixel_formats(extra: &gl::wgl_extra::Wgl, hdc: winapi::HDC)
|
||||||
|
|
||||||
result
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue