1//! The purpose of this library is to provide an OpenGL [`context`] for as many
2//! platforms as possible, abstracting away the underlying differences without
3//! losing access to platform specific extensions.
4//!
5//! However Glutin doesn't force users into using the cross platform
6//! abstractions. When only a particular [`api`] is desired, it can
7//! be used directly.
8//!
9//! The initialization starts by loading and connecting to the platform's
10//! graphics Api when creating a [`display`]. This object is used to create all
11//! the OpenGL objects, such as [`config`], [`context`], and [`surface`].
12
13#![deny(rust_2018_idioms)]
14#![deny(rustdoc::broken_intra_doc_links)]
15#![deny(unsafe_op_in_unsafe_fn)]
16#![deny(improper_ctypes, improper_ctypes_definitions)]
17#![deny(clippy::all)]
18#![deny(missing_debug_implementations)]
19#![deny(missing_docs)]
20#![cfg_attr(feature = "cargo-clippy", deny(warnings))]
21#![cfg_attr(docsrs, feature(doc_auto_cfg))]
22
23#[cfg(all(not(egl_backend), not(glx_backend), not(wgl_backend), not(cgl_backend)))]
24compile_error!("Please select at least one api backend");
25
26pub mod api;
27pub mod config;
28pub mod context;
29pub mod display;
30pub mod error;
31pub mod platform;
32pub mod prelude;
33pub mod surface;
34
35#[cfg(any(egl_backend, glx_backend))]
36mod lib_loading;
37
38pub(crate) mod private {
39 /// Prevent traits from being implemented downstream, since those are used
40 /// purely for documentation organization and simplify platform api
41 /// implementation maintenance.
42 pub trait Sealed {}
43
44 /// `gl_api_dispatch!(match expr; Enum(foo) => foo.something())`
45 /// expands to the equivalent of
46 /// ```ignore
47 /// match self {
48 /// Enum::Egl(foo) => foo.something(),
49 /// Enum::Glx(foo) => foo.something(),
50 /// Enum::Wgl(foo) => foo.something(),
51 /// Enum::Cgl(foo) => foo.something(),
52 /// }
53 /// ```
54 /// The result can be converted to another enum by adding `; as AnotherEnum`
55 macro_rules! gl_api_dispatch {
56 ($what:ident; $enum:ident ( $($c1:tt)* ) => $x:expr; as $enum2:ident ) => {
57 match $what {
58 #[cfg(egl_backend)]
59 $enum::Egl($($c1)*) => $enum2::Egl($x),
60 #[cfg(glx_backend)]
61 $enum::Glx($($c1)*) => $enum2::Glx($x),
62 #[cfg(wgl_backend)]
63 $enum::Wgl($($c1)*) => $enum2::Wgl($x),
64 #[cfg(cgl_backend)]
65 $enum::Cgl($($c1)*) => $enum2::Cgl($x),
66 }
67 };
68 ($what:ident; $enum:ident ( $($c1:tt)* ) => $x:expr) => {
69 match $what {
70 #[cfg(egl_backend)]
71 $enum::Egl($($c1)*) => $x,
72 #[cfg(glx_backend)]
73 $enum::Glx($($c1)*) => $x,
74 #[cfg(wgl_backend)]
75 $enum::Wgl($($c1)*) => $x,
76 #[cfg(cgl_backend)]
77 $enum::Cgl($($c1)*) => $x,
78 }
79 };
80 }
81
82 pub(crate) use gl_api_dispatch;
83}
84