pub fn new(gl: gl::Gl) -> Self {
        // only enable gl debug logging in debug mode, todo: propper logging that
        // isn't just to the terminal
        if cfg!(debug_assertions) {
            enable_gl_debugging(&gl);
        }

        // depth desting is enabled to begin with
        unsafe { gl.Enable(gl::DEPTH_TEST) }

        // initial culling mode is back faces culled
        unsafe { gl.CullFace(gl::BACK) }

        // get maximum number of active texture units
        let mut texture_units = 0;
        unsafe {
            gl.GetIntegerv(gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mut texture_units);
        }

        let mut texture_units = vec![false; texture_units as _];

        // texture unit 0 is used for image loading so don't allow pipelines to
        // use it ever
        texture_units[0] = true;

        GlRenderer {
            gl,
            id: 0,
            backface_culling_enabled: false,
            backface_culling_mode: gl::BACK,
            textures: HashMap::new(),
            buffers: HashMap::new(),
            pipelines: HashMap::new(),
            active_textures: HashMap::new(),
            texture_units,
            depth_function: gl::LESS,
            depth_testing_enabled: true,
            depth_write_enabled: true,
        }
    }
/// Create a new OpenGl rendering backend
Create a new OpenGl rendering backend
Create a new OpenGl rendering backend
pub fn new(gl: gl::Gl) -> Self {
        // only enable gl debug logging in debug mode, todo: propper logging that
        // isn't just to the terminal
        if cfg!(debug_assertions) {
            enable_gl_debugging(&gl);
        }
        // depth desting is enabled to begin with
        unsafe { gl.Enable(gl::DEPTH_TEST) }
        // initial culling mode is back faces culled
        unsafe { gl.CullFace(gl::BACK) }
        // get maximum number of active texture units
        let mut texture_units = 0;
        unsafe {
            gl.GetIntegerv(gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mut texture_units);
        }
        let mut texture_units = vec![false; texture_units as _];
        // texture unit 0 is used for image loading so don't allow pipelines to
        // use it ever
        texture_units[0] = true;
        GlRenderer {
            gl,
            id: 0,
            backface_culling_enabled: false,
            backface_culling_mode: gl::BACK,
            textures: HashMap::new(),
            buffers: HashMap::new(),
            pipelines: HashMap::new(),
            active_textures: HashMap::new(),
            texture_units,
            depth_function: gl::LESS,
            depth_testing_enabled: true,
            depth_write_enabled: true,
        }
    }
pub fn new ( gl : gl :: Gl ) -> Self { // only enable gl debug logging in debug mode, todo: propper logging that // isn't just to the terminal if cfg ! ( debug_assertions ) { enable_gl_debugging ( & gl ) ; } // depth desting is enabled to begin with unsafe { gl . Enable ( gl :: DEPTH_TEST ) } // initial culling mode is back faces culled unsafe { gl . CullFace ( gl :: BACK ) } // get maximum number of active texture units let mut texture_units = 0 ; unsafe { gl . GetIntegerv ( gl :: MAX_COMBINED_TEXTURE_IMAGE_UNITS , & mut texture_units ) ; } let mut texture_units = vec ! [ false texture_units as ] ; // texture unit 0 is used for image loading so don't allow pipelines to // use it ever texture_units [ 0 ] = true ; GlRenderer { gl , id : 0 , backface_culling_enabled : false , backface_culling_mode : gl :: BACK , textures : HashMap :: new ( ) , buffers : HashMap :: new ( ) , pipelines : HashMap :: new ( ) , active_textures : HashMap :: new ( ) , texture_units , depth_function : gl :: LESS , depth_testing_enabled : true , depth_write_enabled : true , } }
Create a new OpenGl rendering backend
Create a new OpenGl rendering backend
gl
gl::Gl
gl
gl::Gl