mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Fix android build
This commit is contained in:
parent
66317f5924
commit
7d43ca32bb
|
@ -257,7 +257,7 @@ impl HeadlessContext {
|
|||
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
|
||||
let context = try!(EglContext::new(egl::ffi::egl::Egl, &builder, egl::NativeDisplay::Android));
|
||||
let context = try!(context.finish_pbuffer());
|
||||
Ok(context)
|
||||
Ok(HeadlessContext(context))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,20 +41,15 @@ pub struct Context {
|
|||
pixel_format: PixelFormat,
|
||||
}
|
||||
|
||||
impl Context {
|
||||
/// Start building an EGL context.
|
||||
///
|
||||
/// This function initializes some things and chooses the pixel format.
|
||||
///
|
||||
/// To finish the process, you must call `.finish(window)` on the `ContextPrototype`.
|
||||
pub fn new<'a>(egl: ffi::egl::Egl, builder: &'a BuilderAttribs<'a>,
|
||||
native_display: NativeDisplay)
|
||||
-> Result<ContextPrototype<'a>, CreationError>
|
||||
{
|
||||
if builder.sharing.is_some() {
|
||||
unimplemented!()
|
||||
#[cfg(target_os = "android")]
|
||||
fn get_native_display(egl: &ffi::egl::Egl,
|
||||
native_display: NativeDisplay) -> *const libc::c_void {
|
||||
unsafe { egl.GetDisplay(ffi::egl::DEFAULT_DISPLAY as *mut _) }
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
fn get_native_display(egl: &ffi::egl::Egl,
|
||||
native_display: NativeDisplay) -> *const libc::c_void {
|
||||
// the first step is to query the list of extensions without any display, if supported
|
||||
let dp_extensions = unsafe {
|
||||
let p = egl.QueryString(ffi::egl::NO_DISPLAY, ffi::egl::EXTENSIONS as i32);
|
||||
|
@ -72,8 +67,7 @@ impl Context {
|
|||
|
||||
let has_dp_extension = |e: &str| dp_extensions.iter().find(|s| s == &e).is_some();
|
||||
|
||||
// calling `eglGetDisplay` or equivalent
|
||||
let display = match native_display {
|
||||
match native_display {
|
||||
// Note: Some EGL implementations are missing the `eglGetPlatformDisplay(EXT)` symbol
|
||||
// despite reporting `EGL_EXT_platform_base`. I'm pretty sure this is a bug.
|
||||
// Therefore we detect whether the symbol is loaded in addition to checking for
|
||||
|
@ -128,6 +122,8 @@ impl Context {
|
|||
ptr::null()) }
|
||||
},
|
||||
|
||||
// TODO: This will never be reached right now, as the android egl bindings
|
||||
// use the static generator, so can't rely on GetPlatformDisplay(EXT).
|
||||
NativeDisplay::Android if has_dp_extension("EGL_KHR_platform_android") &&
|
||||
egl.GetPlatformDisplay.is_loaded() =>
|
||||
{
|
||||
|
@ -152,7 +148,25 @@ impl Context {
|
|||
NativeDisplay::Android | NativeDisplay::Other(None) => {
|
||||
unsafe { egl.GetDisplay(ffi::egl::DEFAULT_DISPLAY as *mut _) }
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
impl Context {
|
||||
/// Start building an EGL context.
|
||||
///
|
||||
/// This function initializes some things and chooses the pixel format.
|
||||
///
|
||||
/// To finish the process, you must call `.finish(window)` on the `ContextPrototype`.
|
||||
pub fn new<'a>(egl: ffi::egl::Egl, builder: &'a BuilderAttribs<'a>,
|
||||
native_display: NativeDisplay)
|
||||
-> Result<ContextPrototype<'a>, CreationError>
|
||||
{
|
||||
if builder.sharing.is_some() {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
// calling `eglGetDisplay` or equivalent
|
||||
let display = get_native_display(&egl, native_display);
|
||||
|
||||
if display.is_null() {
|
||||
return Err(CreationError::OsError("Could not create EGL display object".to_string()));
|
||||
|
|
Loading…
Reference in a new issue