use std::ops::Deref;
use std::rc::Rc;

use super::bindings::{types, Gl as InnerGl};

#[derive(Clone)]
pub struct Gl(Rc<InnerGl>);

impl Gl {
    pub fn load_with<F>(f: F) -> Self
    where
        F: FnMut(&'static str) -> *const types::GLvoid,
    {
        Gl(Rc::new(InnerGl::load_with(f)))
    }
}

impl Deref for Gl {
    type Target = InnerGl;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
