aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-04-12 19:50:09 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-04-12 19:50:09 +0200
commit226c1b96fdd0f03bfec4fed4e2cc36bc769c23e2 (patch)
treefe33220bbd0a544924f09219dcfbe452c3423234
parentd5138d2708f2448ecda64fc20c00bc9b0a758a36 (diff)
parentac23d3114cf40628098d9e5574cb059aa0f22aee (diff)
downloadglutin-226c1b96fdd0f03bfec4fed4e2cc36bc769c23e2.tar.gz
glutin-226c1b96fdd0f03bfec4fed4e2cc36bc769c23e2.zip
Merge pull request #375 from kvark/x11-pixel-format
X11 get_pixel_format and sRGB
-rw-r--r--Cargo.toml2
-rw-r--r--build.rs2
-rw-r--r--src/x11/window/mod.rs34
3 files changed, 36 insertions, 2 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 16fe474..4114108 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "glutin"
-version = "0.0.23"
+version = "0.0.24"
authors = ["tomaka <pierre.krieger1708@gmail.com>"]
description = "Cross-plaform OpenGL context provider."
keywords = ["windowing", "opengl"]
diff --git a/build.rs b/build.rs
index 1824a7a..ca95574 100644
--- a/build.rs
+++ b/build.rs
@@ -52,6 +52,8 @@ fn main() {
khronos_api::GLX_XML,
vec![
"GLX_ARB_create_context".to_string(),
+ "GLX_ARB_framebuffer_sRGB".to_string(),
+ "GLX_EXT_framebuffer_sRGB".to_string(),
"GLX_EXT_swap_control".to_string(),
"GLX_SGI_swap_control".to_string()
],
diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs
index db24312..83f8a19 100644
--- a/src/x11/window/mod.rs
+++ b/src/x11/window/mod.rs
@@ -281,6 +281,7 @@ pub struct Window {
is_closed: AtomicBool,
wm_delete_window: ffi::Atom,
current_size: Cell<(libc::c_int, libc::c_int)>,
+ pixel_format: PixelFormat,
/// Events that have been retreived with XLib but not dispatched with iterators yet
pending_events: Mutex<VecDeque<Event>>,
cursor_state: Mutex<CursorState>,
@@ -328,6 +329,11 @@ impl Window {
visual_attributes.push(val as libc::c_int);
}
+ if let Some(val) = builder.srgb {
+ visual_attributes.push(ffi::glx_extra::FRAMEBUFFER_SRGB_CAPABLE_ARB as libc::c_int);
+ visual_attributes.push(if val {1} else {0});
+ }
+
visual_attributes.push(0);
let mut num_fb: libc::c_int = mem::uninitialized();
@@ -378,6 +384,31 @@ impl Window {
vi_copy
};
+ // querying the chosen pixel format
+ let pixel_format = {
+ let get_attrib = |attrib: libc::c_int| -> i32 {
+ let mut value = 0;
+ unsafe { ffi::glx::GetFBConfigAttrib(display, fb_config, attrib, &mut value); }
+ value
+ };
+
+ PixelFormat {
+ hardware_accelerated: true,
+ red_bits: get_attrib(ffi::GLX_RED_SIZE) as u8,
+ green_bits: get_attrib(ffi::GLX_GREEN_SIZE) as u8,
+ blue_bits: get_attrib(ffi::GLX_BLUE_SIZE) as u8,
+ alpha_bits: get_attrib(ffi::GLX_ALPHA_SIZE) as u8,
+ depth_bits: get_attrib(ffi::GLX_DEPTH_SIZE) as u8,
+ stencil_bits: get_attrib(ffi::GLX_STENCIL_SIZE) as u8,
+ stereoscopy: get_attrib(ffi::GLX_STEREO) != 0,
+ double_buffer: get_attrib(ffi::GLX_DOUBLEBUFFER) != 0,
+ multisampling: if get_attrib(ffi::glx::SAMPLE_BUFFERS as libc::c_int) != 0 {
+ Some(get_attrib(ffi::glx::SAMPLES as libc::c_int) as u16)
+ }else { None },
+ srgb: get_attrib(ffi::glx_extra::FRAMEBUFFER_SRGB_CAPABLE_ARB as libc::c_int) != 0,
+ }
+ };
+
// getting the root window
let root = unsafe { ffi::XDefaultRootWindow(display) };
@@ -600,6 +631,7 @@ impl Window {
is_closed: AtomicBool::new(false),
wm_delete_window: wm_delete_window,
current_size: Cell::new((0, 0)),
+ pixel_format: pixel_format,
pending_events: Mutex::new(VecDeque::new()),
cursor_state: Mutex::new(CursorState::Normal),
};
@@ -734,7 +766,7 @@ impl Window {
}
pub fn get_pixel_format(&self) -> PixelFormat {
- unimplemented!();
+ self.pixel_format.clone()
}
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {