mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Add support for GLESv2 on android. Remove a few warnings.
This commit is contained in:
parent
ef33f19812
commit
02f3287d70
|
@ -1,7 +1,7 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
#![allow(non_uppercase_statics)]
|
#![allow(non_upper_case_globals)]
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,6 @@ pub struct MonitorID;
|
||||||
|
|
||||||
mod ffi;
|
mod ffi;
|
||||||
|
|
||||||
compile_warning!("The Android implementation is not fully working yet")
|
|
||||||
|
|
||||||
pub fn get_available_monitors() -> Vec<MonitorID> {
|
pub fn get_available_monitors() -> Vec<MonitorID> {
|
||||||
vec![ MonitorID ]
|
vec![ MonitorID ]
|
||||||
}
|
}
|
||||||
|
@ -47,7 +45,7 @@ pub struct HeadlessContext(int);
|
||||||
#[cfg(feature = "headless")]
|
#[cfg(feature = "headless")]
|
||||||
impl HeadlessContext {
|
impl HeadlessContext {
|
||||||
/// See the docs in the crate root file.
|
/// 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!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +55,7 @@ impl HeadlessContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// 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!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,13 +96,21 @@ impl Window {
|
||||||
|
|
||||||
android_glue::write_log("eglInitialize succeeded");
|
android_glue::write_log("eglInitialize succeeded");
|
||||||
|
|
||||||
|
let use_gles2 = match builder.gl_version {
|
||||||
|
Some((2, 0)) => true,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
|
||||||
let config = unsafe {
|
let config = unsafe {
|
||||||
let attribute_list = [
|
let mut attribute_list = vec!();
|
||||||
ffi::egl::RED_SIZE as i32, 1,
|
if use_gles2 {
|
||||||
ffi::egl::GREEN_SIZE as i32, 1,
|
attribute_list.push_all([ffi::egl::RENDERABLE_TYPE as i32,
|
||||||
ffi::egl::BLUE_SIZE as i32, 1,
|
ffi::egl::OPENGL_ES2_BIT as i32]);
|
||||||
ffi::egl::NONE 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 num_config: ffi::egl::types::EGLint = mem::uninitialized();
|
||||||
let mut config: ffi::egl::types::EGLConfig = mem::uninitialized();
|
let mut config: ffi::egl::types::EGLConfig = mem::uninitialized();
|
||||||
|
@ -124,7 +130,14 @@ impl Window {
|
||||||
android_glue::write_log("eglChooseConfig succeeded");
|
android_glue::write_log("eglChooseConfig succeeded");
|
||||||
|
|
||||||
let context = unsafe {
|
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() {
|
if context.is_null() {
|
||||||
return Err(OsError(format!("eglCreateContext failed")))
|
return Err(OsError(format!("eglCreateContext failed")))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue