diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-01-22 21:37:07 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-01-22 21:37:07 +0100 |
commit | 1d6b863cd454839b8e3cf1e296cbf8f31fb70029 (patch) | |
tree | 3f4523dd782cb5d4ee554cc38ee9b7fff68705ee /src/x11/window | |
parent | 13be9b2598c1fdce7af61ab05933ba687c95e64c (diff) | |
parent | de3f354566981c8d03a4283a621ac08ae74fc90f (diff) | |
download | glutin-1d6b863cd454839b8e3cf1e296cbf8f31fb70029.tar.gz glutin-1d6b863cd454839b8e3cf1e296cbf8f31fb70029.zip |
Merge pull request #217 from glennw/context-fallback
Some GPU/driver combinations have glxCreateContextAttribsARB present, bu...
Diffstat (limited to 'src/x11/window')
-rw-r--r-- | src/x11/window/mod.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs index 91d7e07..f4c296a 100644 --- a/src/x11/window/mod.rs +++ b/src/x11/window/mod.rs @@ -16,10 +16,18 @@ mod monitor; static THREAD_INIT: Once = ONCE_INIT; +fn x_error_callback(_: *mut ffi::Display, event: *mut ffi::XErrorEvent) -> libc::c_int { + unsafe { + println!("[glutin] x error code={} major={} minor={}!", (*event).error_code, (*event).request_code, (*event).minor_code); + } + 0 +} + fn ensure_thread_init() { THREAD_INIT.call_once(|| { unsafe { ffi::XInitThreads(); + ffi::XSetErrorHandler(x_error_callback); } }); } @@ -322,14 +330,18 @@ impl Window { ptr::null() }; - let context = if extra_functions.CreateContextAttribsARB.is_loaded() { + let mut context = if extra_functions.CreateContextAttribsARB.is_loaded() { extra_functions.CreateContextAttribsARB(display as *mut ffi::glx_extra::types::Display, fb_config, share, 1, attributes.as_ptr()) } else { - ffi::glx::CreateContext(display, &mut visual_infos, share, 1) + ptr::null() }; if context.is_null() { + context = ffi::glx::CreateContext(display, &mut visual_infos, share, 1) + } + + if context.is_null() { return Err(OsError(format!("GL context creation failed"))); } |