aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/glx
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/glx
parenta08388bca1ca275fd1455ceae26ab06c02c81111 (diff)
downloadglutin-aa58f4149a65783b07c0dc401b5854ed80c4915e.tar.gz
glutin-aa58f4149a65783b07c0dc401b5854ed80c4915e.zip
Add a GlContext trait
Diffstat (limited to 'src/api/glx')
-rw-r--r--src/api/glx/mod.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/api/glx/mod.rs b/src/api/glx/mod.rs
index fb86dfd..7aa77e7 100644
--- a/src/api/glx/mod.rs
+++ b/src/api/glx/mod.rs
@@ -2,8 +2,10 @@
use BuilderAttribs;
use CreationError;
+use GlContext;
use GlRequest;
use Api;
+use PixelFormat;
use libc;
use std::ffi::CString;
@@ -140,35 +142,41 @@ impl Context {
context: context,
})
}
+}
- pub fn make_current(&self) {
- let res = unsafe { ffi::glx::MakeCurrent(self.display as *mut _, self.window, self.context) };
+impl GlContext for Context {
+ unsafe fn make_current(&self) {
+ let res = ffi::glx::MakeCurrent(self.display as *mut _, self.window, self.context);
if res == 0 {
panic!("glx::MakeCurrent failed");
}
}
- pub fn is_current(&self) -> bool {
+ fn is_current(&self) -> bool {
unsafe { ffi::glx::GetCurrentContext() == self.context }
}
- pub fn get_proc_address(&self, addr: &str) -> *const () {
+ fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
let addr = CString::new(addr.as_bytes()).unwrap();
let addr = addr.as_ptr();
unsafe {
- ffi::glx::GetProcAddress(addr as *const _) as *const ()
+ ffi::glx::GetProcAddress(addr as *const _) as *const _
}
}
- pub fn swap_buffers(&self) {
+ fn swap_buffers(&self) {
unsafe {
ffi::glx::SwapBuffers(self.display as *mut _, self.window)
}
}
- pub fn get_api(&self) -> ::Api {
+ fn get_api(&self) -> ::Api {
::Api::OpenGl
}
+
+ fn get_pixel_format(&self) -> PixelFormat {
+ unimplemented!();
+ }
}
unsafe impl Send for Context {}