diff --git a/support/android/egl-configs/Cargo.lock b/support/android/egl-configs/Cargo.lock index cc9c0e8b6fb..1f846687f05 100644 --- a/support/android/egl-configs/Cargo.lock +++ b/support/android/egl-configs/Cargo.lock @@ -1,4 +1,55 @@ +[[package]] +name = "bitflags" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "egl-configs" version = "0.1.0" +dependencies = [ + "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] +[[package]] +name = "gl_generator" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "khronos_api 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "khronos_api" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "log" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "xml-rs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[metadata] +"checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" +"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18" +"checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a" +"checksum khronos_api 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "037ab472c33f67b5fbd3e9163a2645319e5356fcd355efa6d4eb7fff4bbcb554" +"checksum log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6fddaa003a65722a7fb9e26b0ce95921fe4ba590542ced664d8ce2fa26f9f3ac" +"checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2" diff --git a/support/android/egl-configs/Cargo.toml b/support/android/egl-configs/Cargo.toml index 9ff8eca7a40..9ce73a900f5 100644 --- a/support/android/egl-configs/Cargo.toml +++ b/support/android/egl-configs/Cargo.toml @@ -1,3 +1,6 @@ [package] name = "egl-configs" version = "0.1.0" + +[build-dependencies] +gl_generator = "0.9" diff --git a/support/android/egl-configs/build.rs b/support/android/egl-configs/build.rs new file mode 100644 index 00000000000..8c0e589607c --- /dev/null +++ b/support/android/egl-configs/build.rs @@ -0,0 +1,16 @@ +extern crate gl_generator; + +use gl_generator::{Registry, Api, Profile, Fallbacks}; +use std::env; +use std::fs::File; +use std::path::PathBuf; + +fn main() { + let out_dir = PathBuf::from(&env::var("OUT_DIR").unwrap()); + let mut file = File::create(&out_dir.join("egl_bindings.rs")).unwrap(); + Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, [ + "EGL_KHR_create_context", + "EGL_KHR_platform_android", + ]) + .write_bindings(gl_generator::StaticGenerator, &mut file).unwrap(); +} diff --git a/support/android/egl-configs/src/ffi.rs b/support/android/egl-configs/src/ffi.rs new file mode 100644 index 00000000000..ce106bb0a94 --- /dev/null +++ b/support/android/egl-configs/src/ffi.rs @@ -0,0 +1,21 @@ +#![allow(non_camel_case_types)] + +use std::os::raw::*; + +pub type NativeDisplayType = *const c_void; +pub type NativePixmapType = *const c_void; +pub type NativeWindowType = *const c_void; + +pub type EGLNativeDisplayType = NativeDisplayType; +pub type EGLNativePixmapType = NativePixmapType; +pub type EGLNativeWindowType = NativeWindowType; + +pub type khronos_utime_nanoseconds_t = khronos_uint64_t; +pub type khronos_uint64_t = u64; +pub type khronos_ssize_t = c_long; +pub type EGLint = i32; + +#[link(name = "EGL")] +extern "C" {} + +include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs")); diff --git a/support/android/egl-configs/src/main.rs b/support/android/egl-configs/src/main.rs index 997012da1a5..d04fc204b1c 100644 --- a/support/android/egl-configs/src/main.rs +++ b/support/android/egl-configs/src/main.rs @@ -1,6 +1,12 @@ +mod ffi; +use ffi::*; + fn main() { - println!("Hello, world!"); - for arg in std::env::args() { - println!("{}", arg); + unsafe { + run() } } + +unsafe fn run() { + let _display = GetDisplay(DEFAULT_DISPLAY as *mut _); +}