mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Implemented get_pixel_format for X11
This commit is contained in:
parent
d5138d2708
commit
ac23d3114c
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "glutin"
|
name = "glutin"
|
||||||
version = "0.0.23"
|
version = "0.0.24"
|
||||||
authors = ["tomaka <pierre.krieger1708@gmail.com>"]
|
authors = ["tomaka <pierre.krieger1708@gmail.com>"]
|
||||||
description = "Cross-plaform OpenGL context provider."
|
description = "Cross-plaform OpenGL context provider."
|
||||||
keywords = ["windowing", "opengl"]
|
keywords = ["windowing", "opengl"]
|
||||||
|
|
2
build.rs
2
build.rs
|
@ -52,6 +52,8 @@ fn main() {
|
||||||
khronos_api::GLX_XML,
|
khronos_api::GLX_XML,
|
||||||
vec![
|
vec![
|
||||||
"GLX_ARB_create_context".to_string(),
|
"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_EXT_swap_control".to_string(),
|
||||||
"GLX_SGI_swap_control".to_string()
|
"GLX_SGI_swap_control".to_string()
|
||||||
],
|
],
|
||||||
|
|
|
@ -281,6 +281,7 @@ pub struct Window {
|
||||||
is_closed: AtomicBool,
|
is_closed: AtomicBool,
|
||||||
wm_delete_window: ffi::Atom,
|
wm_delete_window: ffi::Atom,
|
||||||
current_size: Cell<(libc::c_int, libc::c_int)>,
|
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
|
/// Events that have been retreived with XLib but not dispatched with iterators yet
|
||||||
pending_events: Mutex<VecDeque<Event>>,
|
pending_events: Mutex<VecDeque<Event>>,
|
||||||
cursor_state: Mutex<CursorState>,
|
cursor_state: Mutex<CursorState>,
|
||||||
|
@ -328,6 +329,11 @@ impl Window {
|
||||||
visual_attributes.push(val as libc::c_int);
|
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);
|
visual_attributes.push(0);
|
||||||
|
|
||||||
let mut num_fb: libc::c_int = mem::uninitialized();
|
let mut num_fb: libc::c_int = mem::uninitialized();
|
||||||
|
@ -378,6 +384,31 @@ impl Window {
|
||||||
vi_copy
|
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
|
// getting the root window
|
||||||
let root = unsafe { ffi::XDefaultRootWindow(display) };
|
let root = unsafe { ffi::XDefaultRootWindow(display) };
|
||||||
|
|
||||||
|
@ -600,6 +631,7 @@ impl Window {
|
||||||
is_closed: AtomicBool::new(false),
|
is_closed: AtomicBool::new(false),
|
||||||
wm_delete_window: wm_delete_window,
|
wm_delete_window: wm_delete_window,
|
||||||
current_size: Cell::new((0, 0)),
|
current_size: Cell::new((0, 0)),
|
||||||
|
pixel_format: pixel_format,
|
||||||
pending_events: Mutex::new(VecDeque::new()),
|
pending_events: Mutex::new(VecDeque::new()),
|
||||||
cursor_state: Mutex::new(CursorState::Normal),
|
cursor_state: Mutex::new(CursorState::Normal),
|
||||||
};
|
};
|
||||||
|
@ -734,7 +766,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_pixel_format(&self) -> PixelFormat {
|
pub fn get_pixel_format(&self) -> PixelFormat {
|
||||||
unimplemented!();
|
self.pixel_format.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
|
|
Loading…
Reference in a new issue