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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use std::fmt;
use std::ops;
use std::rc::Rc;
#[allow(clippy::all)]
mod gl {
include!(concat!(env!("OUT_DIR"), "/opengl-bindings.rs"));
}
pub use gl::*;
mod miru {
include!(concat!(env!("OUT_DIR"), "/miru-pinned-opengl-version.rs"));
}
#[derive(Clone)]
pub struct MiruGl {
inner: Rc<Gl>,
}
impl MiruGl {
#[cfg_attr(tarpaulin, skip)]
pub fn load_with<F>(loadfn: F) -> MiruGl
where
F: FnMut(&'static str) -> *const std::ffi::c_void,
{
MiruGl {
inner: Rc::new(Gl::load_with(loadfn)),
}
}
#[cfg_attr(tarpaulin, skip)]
pub fn version(&self) -> (u8, u8) {
miru::OPENGL_VERSION
}
}
impl fmt::Debug for MiruGl {
#[cfg_attr(tarpaulin, skip)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let (major, minor) = self.version();
write!(
f,
"MiruGl: Shared OpenGL {}.{} (Core Profile) api handle",
major, minor
)
}
}
impl ops::Deref for MiruGl {
type Target = Gl;
#[cfg_attr(tarpaulin, skip)]
fn deref(&self) -> &Self::Target {
&self.inner
}
}