-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgl.rs
36 lines (28 loc) · 979 Bytes
/
gl.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::os::raw::c_void;
use crate::modules::capture;
use crate::utils::*;
mod generated {
#![allow(clippy::all)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
pub use generated::*;
pub static GL: MainThreadRefCell<Option<Gl>> = MainThreadRefCell::new(None);
/// # Safety
///
/// `load` must return valid pointers to OpenGL functions or null pointers.
///
/// [`reset_pointers()`] must be called before the library providing pointers is unloaded so the
/// pointers don't go stale.
#[instrument(name = "gl::find_pointers", skip_all)]
pub unsafe fn load_pointers(
marker: MainThreadMarker,
load: impl Fn(&'static str) -> *const c_void,
is_extension_supported: impl Fn(&'static str) -> bool,
) {
*GL.borrow_mut(marker) = Some(Gl::load_with(load));
capture::check_gl_extensions(marker, is_extension_supported);
}
pub fn reset_pointers(marker: MainThreadMarker) {
capture::reset_gl_state(marker);
*GL.borrow_mut(marker) = None;
}