asdf_overlay/lib.rs
1//! ## Asdf Overlay
2//! Asdf overlay let you put overlay infront of existing windows gpu framebuffer.
3//!
4//! It hooks various graphics API call to detect graphical windows in the process.
5//! Asdf overlay automatically decides which graphics API the window is using,
6//! chooses suitable renderer.
7//!
8//! It can also capture inputs going through the target window.
9//! You can listen them or even block them from reaching application handlers.
10//!
11//! ## Example
12//! ```no_run
13//! use asdf_overlay::initialize;
14//! use asdf_overlay::event_sink::OverlayEventSink;
15//!
16//! let module_handle, window_hwnd;
17//! // Initialize asdf-overlay.
18//! initialize(module_handle).expect("initialization failed");
19//!
20//! // Initialize Event sink.
21//! // Without setting it, the overlay will not render.
22//! // This is intended because windows state will be out of sync if you miss any events.
23//! OverlayEventSink::set(move |event| {
24//! // Do something with events.
25//! });
26//!
27//! Backends::with_backend(window_hwnd, |backend| {
28//! // Do something with overlay window backend.
29//! });
30//! ```
31
32#[allow(unsafe_op_in_unsafe_fn, clippy::all)]
33/// Generated OpenGL bindings and global function tables.
34mod gl {
35 include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
36}
37
38#[allow(unsafe_op_in_unsafe_fn, clippy::all)]
39/// Generated WGL bindings and global function tables.
40mod wgl {
41 include!(concat!(env!("OUT_DIR"), "/wgl_bindings.rs"));
42}
43
44pub mod event_sink;
45pub mod surface;
46
47mod hook;
48pub mod interop;
49mod renderer;
50mod texture;
51mod types;
52mod util;
53
54use anyhow::Context;
55
56/// Initialize overlay, hooks.
57///
58/// * Calling more than once will fail.
59/// * Calling with holding loader lock (DllMain) will fail.
60pub fn initialize() -> anyhow::Result<()> {
61 hook::install().context("hook initialization failed")?;
62 Ok(())
63}