wayland-egl-0.29.5/.cargo_vcs_info.json0000644000000001510000000000100133320ustar { "git": { "sha1": "8f4127a21d65cf10189ff0e3b78983e9686dd288" }, "path_in_vcs": "wayland-egl" }wayland-egl-0.29.5/Cargo.toml0000644000000020050000000000100113300ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "wayland-egl" version = "0.29.5" authors = ["Victor Berger "] description = "Bindings to libwayland-egl." documentation = "https://smithay.github.io/wayland-rs/wayland_client/" readme = "README.md" keywords = [ "wayland", "client", ] categories = [ "gui", "api-bindings", ] license = "MIT" repository = "https://github.com/smithay/wayland-rs" [dependencies.wayland-client] version = "0.29.5" features = ["use_system_lib"] [dependencies.wayland-sys] version = "0.29.5" features = ["egl"] wayland-egl-0.29.5/Cargo.toml.orig000064400000000000000000000011151046102023000150120ustar 00000000000000[package] name = "wayland-egl" version = "0.29.5" documentation = "https://smithay.github.io/wayland-rs/wayland_client/" repository = "https://github.com/smithay/wayland-rs" authors = ["Victor Berger "] license = "MIT" edition = "2018" categories = ["gui", "api-bindings"] keywords = ["wayland", "client"] description = "Bindings to libwayland-egl." readme = "README.md" [dependencies] wayland-client = { version = "0.29.5", path = "../wayland-client", features = ["use_system_lib"] } wayland-sys = { version = "0.29.5", path="../wayland-sys", features = ["egl"] } wayland-egl-0.29.5/LICENSE.txt000064400000000000000000000020401046102023000137440ustar 00000000000000Copyright (c) 2015 Victor Berger Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.wayland-egl-0.29.5/README.md000064400000000000000000000013731046102023000134100ustar 00000000000000[![crates.io](https://img.shields.io/crates/v/wayland-egl.svg)](https://crates.io/crates/wayland-egl) [![docs.rs](https://docs.rs/wayland-egl/badge.svg)](https://docs.rs/wayland-egl) [![Continuous Integration](https://github.com/Smithay/wayland-rs/workflows/Continuous%20Integration/badge.svg)](https://github.com/Smithay/wayland-rs/actions?query=workflow%3A%22Continuous+Integration%22) [![codecov](https://codecov.io/gh/Smithay/wayland-rs/branch/master/graph/badge.svg)](https://codecov.io/gh/Smithay/wayland-rs) # wayland-egl This crate provides bindings for OpenGL/Vulkan support for Wayland client apps. It allows to create an `EGLSurface` from any `WlSurface`, which can then play the role of the base surface for initializing an OpenGL or Vulkan context.wayland-egl-0.29.5/src/lib.rs000064400000000000000000000062461046102023000140400ustar 00000000000000#![warn(missing_docs, missing_debug_implementations)] //! EGL utilities //! //! This module contains bindings to the `libwayland-egl.so` library. //! //! This library is used to interface with the OpenGL stack, and creating //! EGL surfaces from a wayland surface. //! //! See WlEglSurface documentation for details. use std::os::raw::c_void; use wayland_client::protocol::wl_surface::WlSurface; use wayland_sys::{client::wl_proxy, egl::*, ffi_dispatch}; /// Checks if the wayland-egl lib is available and can be used /// /// Trying to create an `WlEglSurface` while this function returns /// `false` will result in a panic. pub fn is_available() -> bool { is_lib_available() } unsafe impl Send for WlEglSurface {} unsafe impl Sync for WlEglSurface {} /// EGL surface /// /// This object is a simple wrapper around a `WlSurface` to add the EGL /// capabilities. Just use the `ptr` method once this object is created /// to get the window pointer your OpenGL library is needing to initialize the /// EGL context (you'll most likely need the display ptr as well, that you can /// get via the `ptr` method of the `Proxy` trait on the `WlDisplay` object). #[derive(Debug)] pub struct WlEglSurface { ptr: *mut wl_egl_window, } impl WlEglSurface { /// Create an EGL surface from a wayland surface pub fn new(surface: &WlSurface, width: i32, height: i32) -> WlEglSurface { unsafe { WlEglSurface::new_from_raw(surface.as_ref().c_ptr(), width, height) } } /// Create an EGL surface from a raw pointer to a wayland surface /// /// # Safety /// /// The provided pointer must be a valid `wl_surface` pointer from `libwayland-client`. pub unsafe fn new_from_raw(surface: *mut wl_proxy, width: i32, height: i32) -> WlEglSurface { let ptr = ffi_dispatch!(WAYLAND_EGL_HANDLE, wl_egl_window_create, surface, width, height); WlEglSurface { ptr } } /// Fetch current size of the EGL surface pub fn get_size(&self) -> (i32, i32) { let mut w = 0i32; let mut h = 0i32; unsafe { ffi_dispatch!( WAYLAND_EGL_HANDLE, wl_egl_window_get_attached_size, self.ptr, &mut w as *mut i32, &mut h as *mut i32 ); } (w, h) } /// Resize the EGL surface /// /// The two first arguments `(width, height)` are the new size of /// the surface, the two others `(dx, dy)` represent the displacement /// of the top-left corner of the surface. It allows you to control the /// direction of the resizing if necessary. pub fn resize(&self, width: i32, height: i32, dx: i32, dy: i32) { unsafe { ffi_dispatch!(WAYLAND_EGL_HANDLE, wl_egl_window_resize, self.ptr, width, height, dx, dy) } } /// Raw pointer to the EGL surface /// /// You'll need this pointer to initialize the EGL context in your /// favourite OpenGL lib. pub fn ptr(&self) -> *const c_void { self.ptr as *const c_void } } impl Drop for WlEglSurface { fn drop(&mut self) { unsafe { ffi_dispatch!(WAYLAND_EGL_HANDLE, wl_egl_window_destroy, self.ptr); } } }