aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/android/mod.rs40
-rw-r--r--src/platform/android/mod.rs33
2 files changed, 40 insertions, 33 deletions
diff --git a/src/api/android/mod.rs b/src/api/android/mod.rs
index 83ef12b..7c09a7b 100644
--- a/src/api/android/mod.rs
+++ b/src/api/android/mod.rs
@@ -249,3 +249,43 @@ impl WindowProxy {
unimplemented!()
}
}
+
+pub struct HeadlessContext(EglContext);
+
+impl HeadlessContext {
+ /// See the docs in the crate root file.
+ pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
+ let context = try!(EglContext::new(egl::ffi::egl::Egl, &builder, None));
+ let context = try!(context.finish_pbuffer());
+ Ok(context)
+ }
+}
+
+unsafe impl Send for HeadlessContext {}
+unsafe impl Sync for HeadlessContext {}
+
+impl GlContext for HeadlessContext {
+ unsafe fn make_current(&self) -> Result<(), ContextError> {
+ self.0.make_current()
+ }
+
+ fn is_current(&self) -> bool {
+ self.0.is_current()
+ }
+
+ fn get_proc_address(&self, addr: &str) -> *const libc::c_void {
+ self.0.get_proc_address(addr)
+ }
+
+ fn swap_buffers(&self) -> Result<(), ContextError> {
+ self.0.swap_buffers()
+ }
+
+ fn get_api(&self) -> Api {
+ self.0.get_api()
+ }
+
+ fn get_pixel_format(&self) -> PixelFormat {
+ self.0.get_pixel_format()
+ }
+}
diff --git a/src/platform/android/mod.rs b/src/platform/android/mod.rs
index 50f554b..c90d8ce 100644
--- a/src/platform/android/mod.rs
+++ b/src/platform/android/mod.rs
@@ -1,36 +1,3 @@
#![cfg(target_os = "android")]
pub use api::android::*;
-
-use ContextError;
-
-pub struct HeadlessContext(i32);
-
-impl HeadlessContext {
- /// See the docs in the crate root file.
- pub fn new(_builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
- unimplemented!()
- }
-
- /// See the docs in the crate root file.
- pub unsafe fn make_current(&self) -> Result<(), ContextError> {
- unimplemented!()
- }
-
- /// See the docs in the crate root file.
- pub fn is_current(&self) -> bool {
- unimplemented!()
- }
-
- /// See the docs in the crate root file.
- pub fn get_proc_address(&self, _addr: &str) -> *const () {
- unimplemented!()
- }
-
- pub fn get_api(&self) -> ::Api {
- ::Api::OpenGlEs
- }
-}
-
-unsafe impl Send for HeadlessContext {}
-unsafe impl Sync for HeadlessContext {}