fn program_from_shaders(gl: &gl::Gl, shaders: &[GLuint]) -> Result<GLuint, GlError> {
    let program_id = unsafe { gl.CreateProgram() };

    for &shader in shaders {
        unsafe { gl.AttachShader(program_id, shader) }
    }

    unsafe { gl.LinkProgram(program_id) };

    let mut success = 1;
    unsafe {
        gl.GetProgramiv(program_id, gl::LINK_STATUS, &mut success);
    }

    if success == 0 {
        let mut len = 0;
        unsafe {
            gl.GetProgramiv(program_id, gl::INFO_LOG_LENGTH, &mut len);
        }

        let error = create_whitespace_cstring(len as usize)?;

        unsafe {
            gl.GetProgramInfoLog(
                program_id,
                len,
                std::ptr::null_mut(),
                error.as_ptr() as *mut GLchar,
            )
        }

        return Err(GlError::ShaderLink {
            message: error.to_string_lossy().to_string(),
        });
    }

    for &shader in shaders {
        unsafe { gl.DetachShader(program_id, shader) }
    }

    Ok(program_id)
}
/// Creates an OpenGl shader program from shader IDs
Creates an OpenGl shader program from shader IDs
Creates an OpenGl shader program from shader IDs
fn program_from_shaders(gl: &gl::Gl, shaders: &[GLuint]) -> Result<GLuint, GlError> {
    let program_id = unsafe { gl.CreateProgram() };
    for &shader in shaders {
        unsafe { gl.AttachShader(program_id, shader) }
    }
    unsafe { gl.LinkProgram(program_id) };
    let mut success = 1;
    unsafe {
        gl.GetProgramiv(program_id, gl::LINK_STATUS, &mut success);
    }
    if success == 0 {
        let mut len = 0;
        unsafe {
            gl.GetProgramiv(program_id, gl::INFO_LOG_LENGTH, &mut len);
        }
        let error = create_whitespace_cstring(len as usize)?;
        unsafe {
            gl.GetProgramInfoLog(
                program_id,
                len,
                std::ptr::null_mut(),
                error.as_ptr() as *mut GLchar,
            )
        }
        return Err(GlError::ShaderLink {
            message: error.to_string_lossy().to_string(),
        });
    }
    for &shader in shaders {
        unsafe { gl.DetachShader(program_id, shader) }
    }
    Ok(program_id)
}
fn program_from_shaders ( gl : & gl :: Gl , shaders : & [ GLuint ] ) -> Result < GLuint , GlError > { let program_id = unsafe { gl . CreateProgram ( ) } ; for & shader in shaders { unsafe { gl . AttachShader ( program_id , shader ) } } unsafe { gl . LinkProgram ( program_id ) } ; let mut success = 1 ; unsafe { gl . GetProgramiv ( program_id , gl :: LINK_STATUS , & mut success ) ; } if success == 0 { let mut len = 0 ; unsafe { gl . GetProgramiv ( program_id , gl :: INFO_LOG_LENGTH , & mut len ) ; } let error = create_whitespace_cstring ( len as usize ) ? ; unsafe { gl . GetProgramInfoLog ( program_id , len , std :: ptr :: null_mut ( ) , error . as_ptr ( ) as * mut GLchar , ) } return Err ( GlError :: ShaderLink { message : error . to_string_lossy ( ) . to_string ( ) , } ) ; } for & shader in shaders { unsafe { gl . DetachShader ( program_id , shader ) } } Ok ( program_id ) }
Creates an OpenGl shader program from shader IDs
Creates an OpenGl shader program from shader IDs
gl
&gl::Gl
shaders
&[GLuint]
gl
&gl::Gl
shaders
&[GLuint]