diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2014-11-26 09:16:13 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2014-11-26 09:16:13 +0100 |
commit | 429874ed811de1d8442e1a24c09df66ee77148a3 (patch) | |
tree | 8632a099dec10fb250cc3ae00847d33cf342fbc9 /src/android | |
parent | ef33f198128c8033d23261e9e7466840b66b89ce (diff) | |
parent | 02f3287d7037c6102b27e26a59b7f617ad3567dc (diff) | |
download | glutin-429874ed811de1d8442e1a24c09df66ee77148a3.tar.gz glutin-429874ed811de1d8442e1a24c09df66ee77148a3.zip |
Merge pull request #139 from glennw/android-gles2
Add support for GLESv2 on android. Remove a few warnings.
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/ffi.rs | 2 | ||||
-rw-r--r-- | src/android/mod.rs | 35 |
2 files changed, 25 insertions, 12 deletions
diff --git a/src/android/ffi.rs b/src/android/ffi.rs index b65f44d..5e7060d 100644 --- a/src/android/ffi.rs +++ b/src/android/ffi.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] #![allow(non_snake_case)] #![allow(non_camel_case_types)] -#![allow(non_uppercase_statics)] +#![allow(non_upper_case_globals)] use libc; diff --git a/src/android/mod.rs b/src/android/mod.rs index 27fc8e0..4e24c98 100644 --- a/src/android/mod.rs +++ b/src/android/mod.rs @@ -21,8 +21,6 @@ pub struct MonitorID; mod ffi; -compile_warning!("The Android implementation is not fully working yet") - pub fn get_available_monitors() -> Vec<MonitorID> { vec![ MonitorID ] } @@ -47,7 +45,7 @@ pub struct HeadlessContext(int); #[cfg(feature = "headless")] impl HeadlessContext { /// See the docs in the crate root file. - pub fn new(builder: HeadlessRendererBuilder) -> Result<HeadlessContext, CreationError> { + pub fn new(_builder: HeadlessRendererBuilder) -> Result<HeadlessContext, CreationError> { unimplemented!() } @@ -57,7 +55,7 @@ impl HeadlessContext { } /// See the docs in the crate root file. - pub fn get_proc_address(&self, addr: &str) -> *const () { + pub fn get_proc_address(&self, _addr: &str) -> *const () { unimplemented!() } } @@ -98,13 +96,21 @@ impl Window { android_glue::write_log("eglInitialize succeeded"); + let use_gles2 = match builder.gl_version { + Some((2, 0)) => true, + _ => false, + }; + let config = unsafe { - let attribute_list = [ - ffi::egl::RED_SIZE as i32, 1, - ffi::egl::GREEN_SIZE as i32, 1, - ffi::egl::BLUE_SIZE as i32, 1, - ffi::egl::NONE as i32 - ]; + let mut attribute_list = vec!(); + if use_gles2 { + attribute_list.push_all([ffi::egl::RENDERABLE_TYPE as i32, + ffi::egl::OPENGL_ES2_BIT as i32]); + } + attribute_list.push_all([ffi::egl::RED_SIZE as i32, 1]); + attribute_list.push_all([ffi::egl::GREEN_SIZE as i32, 1]); + attribute_list.push_all([ffi::egl::BLUE_SIZE as i32, 1]); + attribute_list.push(ffi::egl::NONE as i32); let mut num_config: ffi::egl::types::EGLint = mem::uninitialized(); let mut config: ffi::egl::types::EGLConfig = mem::uninitialized(); @@ -124,7 +130,14 @@ impl Window { android_glue::write_log("eglChooseConfig succeeded"); let context = unsafe { - let context = ffi::egl::CreateContext(display, config, ptr::null(), ptr::null()); + let mut context_attributes = vec!(); + if use_gles2 { + context_attributes.push_all([ffi::egl::CONTEXT_CLIENT_VERSION as i32, 2]); + } + context_attributes.push(ffi::egl::NONE as i32); + + let context = ffi::egl::CreateContext(display, config, ptr::null(), + context_attributes.as_ptr()); if context.is_null() { return Err(OsError(format!("eglCreateContext failed"))) } |