diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-07-28 19:59:49 +0200 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-07-28 19:59:49 +0200 |
commit | 829d7a6afc49e0e35d4c782ab500b7bf64130d95 (patch) | |
tree | 6fea39869a1f1572de16fe6f2fe3956ca8bba51e /src/api | |
parent | b3d52cc8fe2cd2f66eedb914a5061f1640129ec4 (diff) | |
parent | 1f6c4d65a61b399d1a476dc19ca3d6a152856286 (diff) | |
download | glutin-829d7a6afc49e0e35d4c782ab500b7bf64130d95.tar.gz glutin-829d7a6afc49e0e35d4c782ab500b7bf64130d95.zip |
Merge pull request #551 from tomaka/android-headless
Implement headless contexts on android
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/android/mod.rs | 40 |
1 files changed, 40 insertions, 0 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() + } +} |