aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11/mod.rs
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-04-30 13:23:37 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-04-30 16:57:07 +0200
commitaa58f4149a65783b07c0dc401b5854ed80c4915e (patch)
treedd5d06aa46a1e18f0b93c2960dacc2cea9c81982 /src/api/x11/mod.rs
parenta08388bca1ca275fd1455ceae26ab06c02c81111 (diff)
downloadglutin-aa58f4149a65783b07c0dc401b5854ed80c4915e.tar.gz
glutin-aa58f4149a65783b07c0dc401b5854ed80c4915e.zip
Add a GlContext trait
Diffstat (limited to 'src/api/x11/mod.rs')
-rw-r--r--src/api/x11/mod.rs91
1 files changed, 47 insertions, 44 deletions
diff --git a/src/api/x11/mod.rs b/src/api/x11/mod.rs
index 6b528ab..9946243 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;
@@ -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()
+ }
+}