Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only apply nvidia hack with nvidia drivers #67

Merged
merged 3 commits into from May 27, 2014
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Use std::c_str instead of std::raw

  • Loading branch information
bjwbell committed May 27, 2014
commit 79a243d0d91481aa702e0c6657e69287f373f418
@@ -27,7 +27,6 @@ use opengles::gl2;
use std::cast;
use std::c_str::CString;
use std::ptr;
use std::str::raw::from_c_str;
use xlib::xlib::{Display, Pixmap, XCreateGC, XCreateImage, XCreatePixmap, XDefaultScreen};
use xlib::xlib::{XDisplayString, XFreePixmap, XGetGeometry, XOpenDisplay, XPutImage, XRootWindow};
use xlib::xlib::{XVisualInfo, ZPixmap};
@@ -97,8 +96,10 @@ impl NativeCompositingGraphicsContext {
let glXGetClientString: extern "C" fn(*Display, c_int) -> *c_char =
cast::transmute(glXGetProcAddress(cast::transmute(&"glXGetClientString\x00"[0])));

This comment has been minimized.

Copy link
@pcwalton

pcwalton May 27, 2014

Contributor

Use the std::c_str functionality instead.

assert!(glXGetClientString as *c_void != ptr::null());
let glx_client_vendor = glXGetClientString(display, 1);
if from_c_str(glx_client_vendor).to_ascii().eq_ignore_case("NVIDIA".to_ascii()) {
let glx_cli_vendor_c_str = CString::new(glXGetClientString(display, 1), false);
let glx_cli_vendor = match glx_cli_vendor_c_str.as_str() { Some(s) => s,
None => fail!("Can't get glx client vendor.") };
if glx_cli_vendor.to_ascii().eq_ignore_case("NVIDIA".to_ascii()) {
// NVidia drives have RGBA configurations that use 24-bit XVisual, not capable of
// representing an alpha-channel in Pixmap form, so we look for the configuration
// with a full set of 32 bits.
@@ -109,11 +110,10 @@ impl NativeCompositingGraphicsContext {
return (visual_info, Some(config))
}
}
}else if number_of_configs != 0 {
} else if number_of_configs != 0 {
let fbconfig = *configs.offset(0);
let vi = glXGetVisualFromFBConfig(glx_display, fbconfig);
return (cast::transmute(vi), Some(fbconfig));

}
fail!("Unable to locate a GLX FB configuration that supports RGBA.");
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.