pub fn load_texture(path: PathBuf, gamma_correction: bool) -> u32 {
    let texture_id = gl::gen_texture();
    let path = path.as_path();

    let img = image::open(&path).expect("Texture failed to load");
    // need two different formats for gamma correction
    let (internal_format, data_format) = match img {
        ImageLuma8(_) => (GL_RED, GL_RED),
        ImageLumaA8(_) => (GL_RG, GL_RG),
        ImageRgb8(_) => (if gamma_correction { GL_SRGB } else { GL_RGB }, GL_RGB),
        // ImageRgba8(_) => (if gammaCorrection { GL_SRGB_ALPHA } else { GL_RGB }, GL_RGBA),
        _ => panic!("unhandled image format"),
    };

    let data = img.as_bytes();

    gl::bind_texture(GL_TEXTURE_2D, texture_id);
    gl::tex_image_2d(
        GL_TEXTURE_2D,
        0,
        internal_format as i32,
        img.width() as i32,
        img.height() as i32,
        0,
        data_format,
        GL_UNSIGNED_BYTE,
        &data,
    );
    gl::generate_mipmap(GL_TEXTURE_2D);

    gl::tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT as i32);
    gl::tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT as i32);
    gl::tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR as i32);
    gl::tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR as i32);

    texture_id
}
// NOTE: not the same version as in common.rs
not the same version as in common.rs
not the same version as in common . rs
pub fn load_texture(path: PathBuf, gamma_correction: bool) -> u32 {
    let texture_id = gl::gen_texture();
    let path = path.as_path();
    let img = image::open(&path).expect("Texture failed to load");
    // need two different formats for gamma correction
    let (internal_format, data_format) = match img {
        ImageLuma8(_) => (GL_RED, GL_RED),
        ImageLumaA8(_) => (GL_RG, GL_RG),
        ImageRgb8(_) => (if gamma_correction { GL_SRGB } else { GL_RGB }, GL_RGB),
        // ImageRgba8(_) => (if gammaCorrection { GL_SRGB_ALPHA } else { GL_RGB }, GL_RGBA),
        _ => panic!("unhandled image format"),
    };
    let data = img.as_bytes();
    gl::bind_texture(GL_TEXTURE_2D, texture_id);
    gl::tex_image_2d(
        GL_TEXTURE_2D,
        0,
        internal_format as i32,
        img.width() as i32,
        img.height() as i32,
        0,
        data_format,
        GL_UNSIGNED_BYTE,
        &data,
    );
    gl::generate_mipmap(GL_TEXTURE_2D);
    gl::tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT as i32);
    gl::tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT as i32);
    gl::tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR as i32);
    gl::tex_parameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR as i32);
    texture_id
}
pub fn load_texture ( path : PathBuf , gamma_correction : bool ) -> u32 { let texture_id = gl :: gen_texture ( ) ; let path = path . as_path ( ) ; let img = image :: open ( & path ) . expect ( " " ) ; // need two different formats for gamma correction let ( internal_format , data_format ) = match img { ImageLuma8 ( _ ) => ( GL_RED , GL_RED ) , ImageLumaA8 ( _ ) => ( GL_RG , GL_RG ) , ImageRgb8 ( _ ) => ( if gamma_correction { GL_SRGB } else { GL_RGB } , GL_RGB ) , // ImageRgba8(_) => (if gammaCorrection { GL_SRGB_ALPHA } else { GL_RGB }, GL_RGBA), _ => panic ! ( " " ) , } ; let data = img . as_bytes ( ) ; gl :: bind_texture ( GL_TEXTURE_2D , texture_id ) ; gl :: tex_image_2d ( GL_TEXTURE_2D , 0 , internal_format as i32 , img . width ( ) as i32 , img . height ( ) as i32 , 0 , data_format , GL_UNSIGNED_BYTE , & data , ) ; gl :: generate_mipmap ( GL_TEXTURE_2D ) ; gl :: tex_parameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_REPEAT as i32 ) ; gl :: tex_parameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_REPEAT as i32 ) ; gl :: tex_parameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR_MIPMAP_LINEAR as i32 ) ; gl :: tex_parameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR as i32 ) ; texture_id }
NOTE: not the same version as in common.rs
NOTE : not the same version as in common . rs
path
PathBuf
gamma_correction
bool
path
PathBuf
gamma_correction
bool