Skip to main content

surfman/
lib.rs

1//! Cross-platform GPU device and surface management.
2//!
3//! You can use this crate to multithread a graphics application so that rendering happens on
4//! multiple threads, sharing textures among them in the most efficient manner. It may also be
5//! useful as a lightweight framework for *just* initializing rendering in native applications.
6//! This is in contrast to crates like SDL, GLFW, winit, and Glutin, all of which have a broader
7//! focus in that they manage windowing and the event loop as well.
8
9#![warn(missing_docs)]
10
11#[macro_use]
12extern crate bitflags;
13#[allow(unused_imports)]
14#[macro_use]
15extern crate log;
16
17#[cfg(all(windows_platform, feature = "sm-angle"))]
18pub mod angle;
19pub(crate) mod base;
20#[cfg(macos_platform)]
21pub mod cgl;
22pub mod chains;
23pub mod connection;
24mod context;
25pub mod device;
26pub mod error;
27mod gl_utils;
28#[cfg(any(android_platform, ohos_platform))]
29pub mod hardware_buffer;
30mod info;
31pub mod macros;
32#[cfg(free_unix)]
33pub mod mesa_surfaceless;
34pub mod multi;
35mod renderbuffers;
36mod surface;
37#[cfg(all(x11_platform, not(wayland_default)))]
38pub mod unix;
39#[cfg(wayland_platform)]
40pub mod wayland;
41#[cfg(all(windows_platform, not(feature = "sm-no-wgl")))]
42pub mod wgl;
43#[cfg(x11_platform)]
44pub mod x11;
45
46#[cfg(all(windows_platform, angle_default))]
47pub use angle as default;
48#[cfg(macos_platform)]
49pub use cgl as default;
50#[cfg(any(android_platform, ohos_platform))]
51pub use hardware_buffer as default;
52#[cfg(all(x11_platform, not(wayland_default)))]
53pub use unix as default;
54#[cfg(wayland_default)]
55pub use wayland as default;
56#[cfg(all(windows_platform, not(angle_default)))]
57pub use wgl as default;
58
59pub use crate::context::{ContextAttributeFlags, ContextAttributes, ContextID};
60pub use crate::error::{Error, WindowingApiError};
61pub use crate::info::{GLApi, GLVersion};
62pub use crate::surface::{SurfaceAccess, SurfaceID, SurfaceInfo, SurfaceType, SystemSurfaceInfo};
63pub use default::connection::Connection;
64pub use default::context::{Context, ContextDescriptor};
65pub use default::device::{Adapter, Device};
66pub use default::surface::{NativeWidget, Surface, SurfaceTexture};
67pub(crate) use glow::{self as gl, Context as Gl};
68pub(crate) use macros::implement_interfaces;
69
70// TODO(pcwalton): Fill this in with other OS's.
71#[cfg(target_os = "macos")]
72pub use base::io_surface::connection::Connection as SystemConnection;
73#[cfg(target_os = "macos")]
74pub use base::io_surface::device::{Adapter as SystemAdapter, Device as SystemDevice};
75#[cfg(target_os = "macos")]
76pub use base::io_surface::surface::Surface as SystemSurface;
77
78#[cfg(any(
79    target_os = "android",
80    target_env = "ohos",
81    all(target_os = "windows", feature = "sm-angle"),
82    unix
83))]
84#[allow(non_camel_case_types)]
85#[allow(clippy::all)]
86mod egl {
87    use std::os::raw::{c_long, c_void};
88    pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
89    pub type khronos_uint64_t = u64;
90    pub type khronos_ssize_t = c_long;
91    pub type EGLint = i32;
92    pub type EGLNativeDisplayType = *const c_void;
93    pub type EGLNativePixmapType = *const c_void;
94    pub type EGLNativeWindowType = *const c_void;
95    pub type NativeDisplayType = EGLNativeDisplayType;
96    pub type NativePixmapType = EGLNativePixmapType;
97    pub type NativeWindowType = EGLNativeWindowType;
98    include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs"));
99}