summaryrefslogtreecommitdiff
path: root/crates/renderer/src/ffi
diff options
context:
space:
mode:
Diffstat (limited to 'crates/renderer/src/ffi')
-rw-r--r--crates/renderer/src/ffi/egl.rs41
-rw-r--r--crates/renderer/src/ffi/glfw.rs7
-rw-r--r--crates/renderer/src/ffi/mod.rs2
3 files changed, 50 insertions, 0 deletions
diff --git a/crates/renderer/src/ffi/egl.rs b/crates/renderer/src/ffi/egl.rs
new file mode 100644
index 0000000..33a39d4
--- /dev/null
+++ b/crates/renderer/src/ffi/egl.rs
@@ -0,0 +1,41 @@
+// from <EGL/egl.h>
+pub const EGL_NONE: EGLenum = 0x3038;
+pub const EGL_WIDTH: EGLenum = 0x3057;
+pub const EGL_HEIGHT: EGLenum = 0x3056;
+
+// from <EGL/eglext.h>
+pub const EGL_LINUX_DMA_BUF_EXT: EGLenum = 0x3270;
+pub const EGL_LINUX_DRM_FOURCC_EXT: EGLenum = 0x3271;
+pub const EGL_DMA_BUF_PLANE0_FD_EXT: EGLenum = 0x3272;
+pub const EGL_DMA_BUF_PLANE0_OFFSET_EXT: EGLenum = 0x3273;
+pub const EGL_DMA_BUF_PLANE0_PITCH_EXT: EGLenum = 0x3274;
+
+#[repr(C)]
+pub struct EGLDisplayTarget(());
+pub type EGLDisplay = *mut EGLDisplayTarget;
+
+#[repr(C)]
+pub struct EGLContextTarget(());
+pub type EGLContext = *mut EGLContextTarget;
+
+#[repr(C)]
+pub struct EGLClientBufferTarget(());
+pub type EGLClientBuffer = *mut EGLClientBufferTarget;
+
+#[repr(C)]
+pub struct EGLImageTarget(());
+pub type EGLImage = *mut EGLImageTarget;
+
+pub type EGLenum = core::ffi::c_uint;
+
+pub type EGLAttrib = libc::intptr_t;
+
+#[link(name = "EGL")]
+extern "C" {
+ pub fn eglCreateImage(d: EGLDisplay, c: EGLContext, t: EGLenum, buf: EGLClientBuffer, attribs: *const EGLAttrib) -> EGLImage;
+}
+
+#[link(name = "GL")]
+extern "C" {
+ pub fn glEGLImageTargetTexture2DOES(t: u32, img: EGLImage);
+}
diff --git a/crates/renderer/src/ffi/glfw.rs b/crates/renderer/src/ffi/glfw.rs
new file mode 100644
index 0000000..1b79089
--- /dev/null
+++ b/crates/renderer/src/ffi/glfw.rs
@@ -0,0 +1,7 @@
+use super::egl::*;
+
+#[link(name = "glfw")]
+extern "C" {
+ pub fn glfwGetEGLDisplay() -> EGLDisplay;
+ pub fn glfwGetEGLContext(w: *mut glfw::ffi::GLFWwindow) -> EGLContext;
+}
diff --git a/crates/renderer/src/ffi/mod.rs b/crates/renderer/src/ffi/mod.rs
new file mode 100644
index 0000000..a98fd71
--- /dev/null
+++ b/crates/renderer/src/ffi/mod.rs
@@ -0,0 +1,2 @@
+pub mod egl;
+pub mod glfw;