diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-02-08 08:03:26 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-02-08 08:03:26 +0100 |
commit | 98345b701f41464941038e5d35d2d006bdf86ba5 (patch) | |
tree | 2fe8d97bdf9ab173f517e0b7d24f05eee4aed0d0 /src | |
parent | cef64c3a8e6d9fb821964444abd43049f1f1ec75 (diff) | |
parent | 81dbaea29e2bcae032da58b26cf24680d1bb780f (diff) | |
download | glutin-98345b701f41464941038e5d35d2d006bdf86ba5.tar.gz glutin-98345b701f41464941038e5d35d2d006bdf86ba5.zip |
Merge pull request #258 from ozkriff/android_color_and_depth_bits
android: Implemented color_bits and depth_bits
Diffstat (limited to 'src')
-rw-r--r-- | src/android/mod.rs | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/android/mod.rs b/src/android/mod.rs index b89bf71..ec6e1a3 100644 --- a/src/android/mod.rs +++ b/src/android/mod.rs @@ -115,18 +115,34 @@ impl Window { _ => false, }; - let config = unsafe { - 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_all(&[ffi::egl::DEPTH_SIZE as i32, 1]); - attribute_list.push(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, + ]); + } + { + let (red, green, blue) = match builder.color_bits.unwrap_or(24) { + 24 => (8, 8, 8), + 16 => (6, 5, 6), + _ => panic!("Bad color_bits"), + }; + attribute_list.push_all(&[ffi::egl::RED_SIZE as i32, red]); + attribute_list.push_all(&[ffi::egl::GREEN_SIZE as i32, green]); + attribute_list.push_all(&[ffi::egl::BLUE_SIZE as i32, blue]); + } + + attribute_list.push_all(&[ + ffi::egl::DEPTH_SIZE as i32, + builder.depth_bits.unwrap_or(8) as i32, + ]); + + attribute_list.push(ffi::egl::NONE as i32); + + let config = unsafe { let mut num_config: ffi::egl::types::EGLint = mem::uninitialized(); let mut config: ffi::egl::types::EGLConfig = mem::uninitialized(); if ffi::egl::ChooseConfig(display, attribute_list.as_ptr(), &mut config, 1, |