From c9b1b91b8cb7e43c0908c04afaefb8e49e0f2b35 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 27 Jul 2015 09:52:51 +0200 Subject: Load the EGL library in platform/windows --- src/api/win32/init.rs | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'src/api/win32/init.rs') diff --git a/src/api/win32/init.rs b/src/api/win32/init.rs index fdb88c9..e6f0648 100644 --- a/src/api/win32/init.rs +++ b/src/api/win32/init.rs @@ -32,6 +32,7 @@ use api::wgl; use api::wgl::Context as WglContext; use api::egl; use api::egl::Context as EglContext; +use api::egl::ffi::egl::Egl; pub enum RawContext { Egl(egl::ffi::egl::types::EGLContext), @@ -41,9 +42,12 @@ pub enum RawContext { unsafe impl Send for RawContext {} unsafe impl Sync for RawContext {} -pub fn new_window(builder: BuilderAttribs<'static>, builder_sharelists: Option) +pub fn new_window(builder: BuilderAttribs<'static>, builder_sharelists: Option, + egl: Option<&Egl>) -> Result { + let egl = egl.map(|e| e.clone()); + // initializing variables to be sent to the task let title = OsStr::new(&builder.title).encode_wide().chain(Some(0).into_iter()) @@ -56,7 +60,7 @@ pub fn new_window(builder: BuilderAttribs<'static>, builder_sharelists: Option tx.send(Ok(w)).ok(), Err(e) => { tx.send(Err(e)).ok(); @@ -83,7 +87,8 @@ pub fn new_window(builder: BuilderAttribs<'static>, builder_sharelists: Option, builder: BuilderAttribs<'static>, - builder_sharelists: Option) -> Result + builder_sharelists: Option, egl: Option) + -> Result { // registering the window class let class_name = register_window_class(); @@ -159,24 +164,7 @@ unsafe fn init(title: Vec, builder: BuilderAttribs<'static>, // creating the OpenGL context let context = match builder.gl_version { GlRequest::Specific(Api::OpenGlEs, (major, minor)) => { - // trying to load EGL from the ATI drivers - - // TODO: use LoadLibraryA instead - let dll_name = if cfg!(target_pointer_width = "64") { - "atio6axx.dll" - } else { - "atioglxx.dll" - }; - let dll_name = OsStr::new(dll_name).encode_wide().chain(Some(0).into_iter()) - .collect::>(); - let dll = unsafe { kernel32::LoadLibraryW(dll_name.as_ptr()) }; - - if !dll.is_null() { - let egl = ::api::egl::ffi::egl::Egl::load_with(|name| { - let name = CString::new(name).unwrap(); - unsafe { kernel32::GetProcAddress(dll, name.as_ptr()) as *const libc::c_void } - }); - + if let Some(egl) = egl { if let Ok(c) = EglContext::new(egl, &builder, Some(ptr::null())) .and_then(|p| p.finish(real_window.0)) { -- cgit v1.2.3