From 19475f8521c6ce92a9b8b2c22e13613e718b2a9e Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 22 Jan 2015 12:02:02 +1000 Subject: Some GPU/driver combinations have glxCreateContextAttribsARB present, but it fails with an X error. In this case, catch the X error and fall back to the old method of creating a context. --- src/x11/window/mod.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/x11/window') diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs index 91d7e07..1457c63 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!("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,13 +330,17 @@ 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"))); } -- cgit v1.2.3 From de3f354566981c8d03a4283a621ac08ae74fc90f Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 23 Jan 2015 06:01:22 +1000 Subject: Fix log prefix --- src/x11/window/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/x11/window') diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs index 1457c63..f4c296a 100644 --- a/src/x11/window/mod.rs +++ b/src/x11/window/mod.rs @@ -18,7 +18,7 @@ static THREAD_INIT: Once = ONCE_INIT; fn x_error_callback(_: *mut ffi::Display, event: *mut ffi::XErrorEvent) -> libc::c_int { unsafe { - println!("x error code={} major={} minor={}!", (*event).error_code, (*event).request_code, (*event).minor_code); + println!("[glutin] x error code={} major={} minor={}!", (*event).error_code, (*event).request_code, (*event).minor_code); } 0 } -- cgit v1.2.3