aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/caca
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-04-30 17:32:53 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-04-30 17:32:53 +0200
commitd3fbbfb7a777f8f7b6a39b66dd982cbc8cb802ba (patch)
treedd5d06aa46a1e18f0b93c2960dacc2cea9c81982 /src/api/caca
parenta08388bca1ca275fd1455ceae26ab06c02c81111 (diff)
parentaa58f4149a65783b07c0dc401b5854ed80c4915e (diff)
downloadglutin-d3fbbfb7a777f8f7b6a39b66dd982cbc8cb802ba.tar.gz
glutin-d3fbbfb7a777f8f7b6a39b66dd982cbc8cb802ba.zip
Merge pull request #412 from tomaka/glcontext-trait
Add a GlContext trait
Diffstat (limited to 'src/api/caca')
-rw-r--r--src/api/caca/mod.rs72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/api/caca/mod.rs b/src/api/caca/mod.rs
index d8199dd..da7810a 100644
--- a/src/api/caca/mod.rs
+++ b/src/api/caca/mod.rs
@@ -3,9 +3,11 @@
use libc;
use api::osmesa::OsMesaContext;
+use Api;
use BuilderAttribs;
use CreationError;
use Event;
+use GlContext;
use PixelFormat;
use CursorState;
use MouseCursor;
@@ -169,34 +171,6 @@ impl Window {
}
}
- pub unsafe fn make_current(&self) {
- self.opengl.make_current()
- }
-
- pub fn is_current(&self) -> bool {
- self.opengl.is_current()
- }
-
- pub fn get_proc_address(&self, addr: &str) -> *const () {
- self.opengl.get_proc_address(addr) as *const _
- }
-
- pub fn swap_buffers(&self) {
- unsafe {
- let canvas = (self.libcaca.caca_get_canvas)(self.display);
- let width = (self.libcaca.caca_get_canvas_width)(canvas);
- let height = (self.libcaca.caca_get_canvas_height)(canvas);
-
- let buffer = self.opengl.get_framebuffer().chunks(self.opengl.get_dimensions().0 as usize)
- .flat_map(|i| i.iter().cloned()).rev().collect::<Vec<u32>>();
-
- (self.libcaca.caca_dither_bitmap)(canvas, 0, 0, width as libc::c_int,
- height as libc::c_int, self.dither,
- buffer.as_ptr() as *const _);
- (self.libcaca.caca_refresh_display)(self.display);
- };
- }
-
pub fn platform_display(&self) -> *mut libc::c_void {
unimplemented!()
}
@@ -205,10 +179,6 @@ impl Window {
unimplemented!()
}
- pub fn get_api(&self) -> ::Api {
- self.opengl.get_api()
- }
-
pub fn get_pixel_format(&self) -> PixelFormat {
unimplemented!();
}
@@ -232,6 +202,44 @@ impl Window {
}
}
+impl GlContext for Window {
+ unsafe fn make_current(&self) {
+ self.opengl.make_current()
+ }
+
+ fn is_current(&self) -> bool {
+ self.opengl.is_current()
+ }
+
+ fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
+ self.opengl.get_proc_address(addr)
+ }
+
+ fn swap_buffers(&self) {
+ unsafe {
+ let canvas = (self.libcaca.caca_get_canvas)(self.display);
+ let width = (self.libcaca.caca_get_canvas_width)(canvas);
+ let height = (self.libcaca.caca_get_canvas_height)(canvas);
+
+ let buffer = self.opengl.get_framebuffer().chunks(self.opengl.get_dimensions().0 as usize)
+ .flat_map(|i| i.iter().cloned()).rev().collect::<Vec<u32>>();
+
+ (self.libcaca.caca_dither_bitmap)(canvas, 0, 0, width as libc::c_int,
+ height as libc::c_int, self.dither,
+ buffer.as_ptr() as *const _);
+ (self.libcaca.caca_refresh_display)(self.display);
+ };
+ }
+
+ fn get_api(&self) -> Api {
+ self.opengl.get_api()
+ }
+
+ fn get_pixel_format(&self) -> PixelFormat {
+ self.opengl.get_pixel_format()
+ }
+}
+
impl Drop for Window {
fn drop(&mut self) {
unsafe {