func fromPng(file string) (uint32, error) {
	r, err := loader.Load(file)
	if err != nil {
		return 0, err
	}
	img, _, err := image.Decode(r)
	if err != nil {
		return 0, err
	}

	rgba := image.NewRGBA(img.Bounds())
	if rgba.Stride != rgba.Rect.Size().X*4 {
		return 0, fmt.Errorf("unsupported stride")
	}
	draw.Draw(rgba, rgba.Bounds(), img, image.Point{0, 0}, draw.Src)

	var texture uint32
	gl.GenTextures(1, &texture)
	gl.ActiveTexture(gl.TEXTURE0)
	gl.BindTexture(gl.TEXTURE_2D, texture)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_LOD, 1)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAX_LOD, 4)
	gl.TexImage2D(
		gl.TEXTURE_2D,
		0,
		gl.RGBA,
		int32(rgba.Rect.Size().X),
		int32(rgba.Rect.Size().Y),
		0,
		gl.RGBA,
		gl.UNSIGNED_BYTE,
		gl.Ptr(rgba.Pix))
	gl.GenerateMipmap(gl.TEXTURE_2D)

	return texture, nil
}
// fromPng builds a texture from the provided Png file.
fromPng builds a texture from the provided Png file.
// fromPng builds a texture from the provided Png file .
func fromPng(file string) (uint32, error) {
	r, err := loader.Load(file)
	if err != nil {
		return 0, err
	}
	img, _, err := image.Decode(r)
	if err != nil {
		return 0, err
	}
	rgba := image.NewRGBA(img.Bounds())
	if rgba.Stride != rgba.Rect.Size().X*4 {
		return 0, fmt.Errorf("unsupported stride")
	}
	draw.Draw(rgba, rgba.Bounds(), img, image.Point{0, 0}, draw.Src)
	var texture uint32
	gl.GenTextures(1, &texture)
	gl.ActiveTexture(gl.TEXTURE0)
	gl.BindTexture(gl.TEXTURE_2D, texture)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_LOD, 1)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAX_LOD, 4)
	gl.TexImage2D(
		gl.TEXTURE_2D,
		0,
		gl.RGBA,
		int32(rgba.Rect.Size().X),
		int32(rgba.Rect.Size().Y),
		0,
		gl.RGBA,
		gl.UNSIGNED_BYTE,
		gl.Ptr(rgba.Pix))
	gl.GenerateMipmap(gl.TEXTURE_2D)
	return texture, nil
}
func fromPng ( file string ) ( uint32 , error ) { r , err := loader . Load ( file ) if err != nil { return 0 , err } img , _ , err := image . Decode ( r ) if err != nil { return 0 , err } rgba := image . NewRGBA ( img . Bounds ( ) ) if rgba . Stride != rgba . Rect . Size ( ) . X * 4 { return 0 , fmt . Errorf ( " " ) } draw . Draw ( rgba , rgba . Bounds ( ) , img , image . Point { 0 , 0 } , draw . Src ) var texture uint32 gl . GenTextures ( 1 , & texture ) gl . ActiveTexture ( gl . TEXTURE0 ) gl . BindTexture ( gl . TEXTURE_2D , texture ) gl . TexParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MIN_FILTER , gl . LINEAR_MIPMAP_LINEAR ) gl . TexParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MAG_FILTER , gl . LINEAR ) gl . TexParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_S , gl . REPEAT ) gl . TexParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_T , gl . REPEAT ) gl . TexParameterf ( gl . TEXTURE_2D , gl . TEXTURE_MIN_LOD , 1 ) gl . TexParameterf ( gl . TEXTURE_2D , gl . TEXTURE_MAX_LOD , 4 ) gl . TexImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , int32 ( rgba . Rect . Size ( ) . X ) , int32 ( rgba . Rect . Size ( ) . Y ) , 0 , gl . RGBA , gl . UNSIGNED_BYTE , gl . Ptr ( rgba . Pix ) ) gl . GenerateMipmap ( gl . TEXTURE_2D ) return texture , nil }
fromPng builds a texture from the provided Png file.
fromPng builds a texture from the provided Png file .