reverie_engine_opengl/
gl.rs

1//! OpenGLのバインディング
2//!
3//! OpenGL 3.3 Core Profile
4//!
5//! 機能拡張は無し
6
7#[allow(clippy::all)]
8#[allow(clippy::nursery)]
9mod bindings {
10    include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
11}
12
13pub use bindings::*;
14
15use std::fmt::Debug;
16use std::rc::Rc;
17#[derive(Clone)]
18/// 実体は[`std::rc::Rc`]なのでいくらでもクローンして良い
19pub struct Gl {
20    inner: Rc<bindings::Gl>,
21}
22
23impl Gl {
24    pub fn load_with<F>(loadfn: F) -> Self
25    where
26        F: FnMut(&'static str) -> *const types::GLvoid,
27    {
28        Self {
29            inner: Rc::new(bindings::Gl::load_with(loadfn)),
30        }
31    }
32}
33
34impl Debug for Gl {
35    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36        f.write_str("<OpenGL Bindings>")
37    }
38}
39
40use std::ops::Deref;
41impl Deref for Gl {
42    type Target = bindings::Gl;
43
44    fn deref(&self) -> &bindings::Gl {
45        &self.inner
46    }
47}