diff options
Diffstat (limited to 'src/api/x11')
-rw-r--r-- | src/api/x11/mod.rs | 97 |
1 files changed, 50 insertions, 47 deletions
diff --git a/src/api/x11/mod.rs b/src/api/x11/mod.rs index 252b22e..7d7c048 100644 --- a/src/api/x11/mod.rs +++ b/src/api/x11/mod.rs @@ -13,6 +13,7 @@ use std::sync::{Arc, Mutex, Once, ONCE_INIT}; use Api; use CursorState; +use GlContext; use GlRequest; use PixelFormat; @@ -411,9 +412,9 @@ impl Window { PixelFormat { hardware_accelerated: true, - red_bits: get_attrib(ffi::glx::RED_SIZE as libc::c_int) as u8, - green_bits: get_attrib(ffi::glx::GREEN_SIZE as libc::c_int) as u8, - blue_bits: get_attrib(ffi::glx::BLUE_SIZE as libc::c_int) as u8, + color_bits: get_attrib(ffi::glx::RED_SIZE as libc::c_int) as u8 + + get_attrib(ffi::glx::GREEN_SIZE as libc::c_int) as u8 + + get_attrib(ffi::glx::BLUE_SIZE as libc::c_int) as u8, alpha_bits: get_attrib(ffi::glx::ALPHA_SIZE as libc::c_int) as u8, depth_bits: get_attrib(ffi::glx::DEPTH_SIZE as libc::c_int) as u8, stencil_bits: get_attrib(ffi::glx::STENCIL_SIZE as libc::c_int) as u8, @@ -674,38 +675,6 @@ impl Window { } } - pub unsafe fn make_current(&self) { - match self.x.context { - Context::Glx(ref ctxt) => ctxt.make_current(), - Context::Egl(ref ctxt) => ctxt.make_current(), - Context::None => {} - } - } - - pub fn is_current(&self) -> bool { - match self.x.context { - Context::Glx(ref ctxt) => ctxt.is_current(), - Context::Egl(ref ctxt) => ctxt.is_current(), - Context::None => panic!() - } - } - - pub fn get_proc_address(&self, addr: &str) -> *const () { - match self.x.context { - Context::Glx(ref ctxt) => ctxt.get_proc_address(addr), - Context::Egl(ref ctxt) => ctxt.get_proc_address(addr), - Context::None => ptr::null() - } - } - - pub fn swap_buffers(&self) { - match self.x.context { - Context::Glx(ref ctxt) => ctxt.swap_buffers(), - Context::Egl(ref ctxt) => ctxt.swap_buffers(), - Context::None => {} - } - } - pub fn platform_display(&self) -> *mut libc::c_void { self.x.display as *mut libc::c_void } @@ -714,18 +683,6 @@ impl Window { unimplemented!() } - /// See the docs in the crate root file. - pub fn get_api(&self) -> ::Api { - match self.x.context { - Context::Glx(ref ctxt) => ctxt.get_api(), - Context::Egl(ref ctxt) => ctxt.get_api(), - Context::None => panic!() - } - } - - pub fn get_pixel_format(&self) -> PixelFormat { - self.pixel_format.clone() - } pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) { } @@ -828,3 +785,49 @@ impl Window { Ok(()) } } + +impl GlContext for Window { + unsafe fn make_current(&self) { + match self.x.context { + Context::Glx(ref ctxt) => ctxt.make_current(), + Context::Egl(ref ctxt) => ctxt.make_current(), + Context::None => {} + } + } + + fn is_current(&self) -> bool { + match self.x.context { + Context::Glx(ref ctxt) => ctxt.is_current(), + Context::Egl(ref ctxt) => ctxt.is_current(), + Context::None => panic!() + } + } + + fn get_proc_address(&self, addr: &str) -> *const libc::c_void { + match self.x.context { + Context::Glx(ref ctxt) => ctxt.get_proc_address(addr), + Context::Egl(ref ctxt) => ctxt.get_proc_address(addr), + Context::None => ptr::null() + } + } + + fn swap_buffers(&self) { + match self.x.context { + Context::Glx(ref ctxt) => ctxt.swap_buffers(), + Context::Egl(ref ctxt) => ctxt.swap_buffers(), + Context::None => {} + } + } + + fn get_api(&self) -> Api { + match self.x.context { + Context::Glx(ref ctxt) => ctxt.get_api(), + Context::Egl(ref ctxt) => ctxt.get_api(), + Context::None => panic!() + } + } + + fn get_pixel_format(&self) -> PixelFormat { + self.pixel_format.clone() + } +} |