pub fn new_from_strings(gl : Rc<glow::Context>, vx_shader:&str, fg_shader:&str )-> Self{

        unsafe {

            let shader_sources = [
                (glow::VERTEX_SHADER, vx_shader),
                (glow::FRAGMENT_SHADER, fg_shader),
            ];
        
            let mut shaders = Vec::with_capacity(shader_sources.len());
        
            // compile the shaders
            let program = gl.create_program().expect("Cannot create program");
           
            for (shader_type, shader_source) in shader_sources.iter() {
                let shader = gl
                    .create_shader(*shader_type)
                    .expect(&format!( "Cannot create shader: {}", shader_source));

                gl.shader_source(shader, shader_source);
                gl.compile_shader(shader);
    
                // println!("Compiling {}", shader_source );
                if !gl.get_shader_compile_status(shader) {
                    panic!( "{}", gl.get_shader_info_log(shader));
                }
                gl.attach_shader(program, shader);
                shaders.push(shader);
            }
    
            // link the shaders
            gl.link_program(program);
            if !gl.get_program_link_status(program) {
                panic!( "{}",gl.get_program_info_log(program));
            }
    
            for shader in shaders {
                gl.detach_shader(program, shader);
                gl.delete_shader(shader);
            }

            Self {
                gl : gl,
                program : Some(program),
                uniform_lookup: RefCell::new(HashMap::new()),
            }
        }
    }
/// Create new shader form two strings
/// ------------------------------------------------------------------------
Create new shader form two strings
Create new shader form two strings
pub fn new_from_strings(gl : Rc<glow::Context>, vx_shader:&str, fg_shader:&str )-> Self{
        unsafe {
            let shader_sources = [
                (glow::VERTEX_SHADER, vx_shader),
                (glow::FRAGMENT_SHADER, fg_shader),
            ];
            let mut shaders = Vec::with_capacity(shader_sources.len());
            // compile the shaders
            let program = gl.create_program().expect("Cannot create program");
            for (shader_type, shader_source) in shader_sources.iter() {
                let shader = gl
                    .create_shader(*shader_type)
                    .expect(&format!( "Cannot create shader: {}", shader_source));
                gl.shader_source(shader, shader_source);
                gl.compile_shader(shader);
                // println!("Compiling {}", shader_source );
                if !gl.get_shader_compile_status(shader) {
                    panic!( "{}", gl.get_shader_info_log(shader));
                }
                gl.attach_shader(program, shader);
                shaders.push(shader);
            }
            // link the shaders
            gl.link_program(program);
            if !gl.get_program_link_status(program) {
                panic!( "{}",gl.get_program_info_log(program));
            }
            for shader in shaders {
                gl.detach_shader(program, shader);
                gl.delete_shader(shader);
            }
            Self {
                gl : gl,
                program : Some(program),
                uniform_lookup: RefCell::new(HashMap::new()),
            }
        }
    }
pub fn new_from_strings ( gl : Rc < glow :: Context > , vx_shader : & str , fg_shader : & str ) -> Self { unsafe { let shader_sources = [ ( glow :: VERTEX_SHADER , vx_shader ) , ( glow :: FRAGMENT_SHADER , fg_shader ) , ] ; let mut shaders = Vec :: with_capacity ( shader_sources . len ( ) ) ; // compile the shaders let program = gl . create_program ( ) . expect ( " " ) ; for ( shader_type , shader_source ) in shader_sources . iter ( ) { let shader = gl . create_shader ( * shader_type ) . expect ( & format ! ( " " shader_source ) ) ; gl . shader_source ( shader , shader_source ) ; gl . compile_shader ( shader ) ; // println!("Compiling {}", shader_source ); if ! gl . get_shader_compile_status ( shader ) { panic ! ( " " gl get_shader_info_log ( shader ) ) ; } gl . attach_shader ( program , shader ) ; shaders . push ( shader ) ; } // link the shaders gl . link_program ( program ) ; if ! gl . get_program_link_status ( program ) { panic ! ( " " gl get_program_info_log ( program ) ) ; } for shader in shaders { gl . detach_shader ( program , shader ) ; gl . delete_shader ( shader ) ; } Self { gl : gl , program : Some ( program ) , uniform_lookup : RefCell :: new ( HashMap :: new ( ) ) , } } }
Create new shader form two strings
Create new shader form two strings
gl
Rc<glow::Context>
vx_shader
&str
fg_shader
&str