diff options
author | Tomaka17 <pierre.krieger1708@gmail.com> | 2014-08-12 09:42:48 +0200 |
---|---|---|
committer | Tomaka17 <pierre.krieger1708@gmail.com> | 2014-08-12 09:42:48 +0200 |
commit | 53b9d6398c5e88ce5ab67be06837ee0f285e516f (patch) | |
tree | b4d698b0c6452036186d89da3deb68851e5d1739 /src | |
parent | f452999b8ce27ae7aa99f7efdb3bd651e55306a7 (diff) | |
download | glutin-53b9d6398c5e88ce5ab67be06837ee0f285e516f.tar.gz glutin-53b9d6398c5e88ce5ab67be06837ee0f285e516f.zip |
Remove dummy context creation for X11
Diffstat (limited to 'src')
-rw-r--r-- | src/x11/mod.rs | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/src/x11/mod.rs b/src/x11/mod.rs index e7a064d..3286b99 100644 --- a/src/x11/mod.rs +++ b/src/x11/mod.rs @@ -141,39 +141,19 @@ impl Window { // getting the pointer to glXCreateContextAttribs let create_context_attribs = unsafe { - // creating the dummy context - let dummy_context = - ffi::glXCreateContext(display, &visual_infos, ptr::null(), 1); - if dummy_context.is_null() { - return Err(format!("glXCreateContext failed")); - } - - if ffi::glXMakeCurrent(display, window, dummy_context) == 0 { - return Err(format!("glXMakeCurrent with dummy context failed")); - } + let mut addr = ffi::glXGetProcAddress(b"glXCreateContextAttribs".as_ptr() + as *const u8) as *const (); - // getting the pointer - let fn_ptr = { - let mut addr = ffi::glXGetProcAddress(b"glXCreateContextAttribs".as_ptr() + if addr.is_null() { + addr = ffi::glXGetProcAddress(b"glXCreateContextAttribsARB".as_ptr() as *const u8) as *const (); - - if addr.is_null() { - addr = ffi::glXGetProcAddress(b"glXCreateContextAttribsARB".as_ptr() - as *const u8) as *const (); - } - - addr.to_option().map(|addr| { - let addr: extern "system" fn(*mut ffi::Display, ffi::GLXFBConfig, ffi::GLXContext, - ffi::Bool, *const libc::c_int) -> ffi::GLXContext = mem::transmute(addr); - addr - }) - }; - - // cleaning up - ffi::glXMakeCurrent(ptr::mut_null(), 0, ptr::null()); - ffi::glXDestroyContext(display, dummy_context); - - fn_ptr + } + + addr.to_option().map(|addr| { + let addr: extern "system" fn(*mut ffi::Display, ffi::GLXFBConfig, ffi::GLXContext, + ffi::Bool, *const libc::c_int) -> ffi::GLXContext = mem::transmute(addr); + addr + }) }; // creating IM |