1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#[macro_use] extern crate lazy_static;
#[cfg(test)] extern crate dlopen;

pub mod shaders;
#[cfg(test)] mod tests;

#[cfg(all(windows, feature = "egl"))]
pub mod gles {
    pub mod ffi {
        include!(concat!(env!("OUT_DIR"), "/gles_bindings.rs"));
    }
}

#[cfg(all(windows, feature = "egl"))]
pub mod egl {
    use std::ffi::CString;
    use std::os::raw::c_void;

    pub mod ffi {
        use std::os::raw::{c_void, c_long};

        include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs"));

        // Adapted from https://github.com/tomaka/glutin/blob/1f3b8360cb/src/api/egl/ffi.rs
        #[allow(non_camel_case_types)] pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
        #[allow(non_camel_case_types)] pub type khronos_uint64_t = u64;
        #[allow(non_camel_case_types)] pub type khronos_ssize_t = c_long;
        pub type EGLint = i32;
        pub type EGLNativeDisplayType = *const c_void;
        pub type EGLNativePixmapType = *const c_void;
        pub type EGLNativeWindowType = *const c_void;
        pub type NativeDisplayType = EGLNativeDisplayType;
        pub type NativePixmapType = EGLNativePixmapType;
        pub type NativeWindowType = EGLNativeWindowType;

        // Adapted from https://chromium.googlesource.com/angle/angle/+/master/include/EGL/eglext_angle.h
        pub type EGLDeviceEXT = *mut c_void;
        pub const EXPERIMENTAL_PRESENT_PATH_ANGLE: types::EGLenum = 0x33A4;
        pub const EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE: types::EGLenum = 0x33A9;
        pub const D3D_TEXTURE_ANGLE: types::EGLenum = 0x33A3;
        pub const FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE: types::EGLenum = 0x33A6;

        extern "C" {
            pub fn eglCreateDeviceANGLE(
                device_type: types::EGLenum,
                device: *mut c_void,
                attrib_list: *const types::EGLAttrib,
            ) -> EGLDeviceEXT;

            pub fn eglReleaseDeviceANGLE(device: EGLDeviceEXT) -> types::EGLBoolean;
        }
    }
}