Initial commit
This commit is contained in:
43
internal/asset/texture.go
Normal file
43
internal/asset/texture.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package asset
|
||||
|
||||
import (
|
||||
_ "image/png"
|
||||
|
||||
"log"
|
||||
|
||||
"edgaru089.ml/go/gl01/internal/util"
|
||||
)
|
||||
|
||||
// WorldTextureAtlas holds all the world block textures.
|
||||
var WorldTextureAtlas util.Atlas
|
||||
|
||||
func InitWorldTextureAtlas() {
|
||||
if WorldTextureAtlas.HasBuilt() {
|
||||
return
|
||||
}
|
||||
|
||||
files, err := FS.ReadDir("texture/world")
|
||||
if err != nil {
|
||||
panic("InitWorldTextureAtlas: embed.FS.ReadDir(\"texture/world\"): " + err.Error())
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := f.Name()
|
||||
|
||||
file, err := FS.Open("texture/world/" + name)
|
||||
if err != nil { // Shouldn't be error?
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = WorldTextureAtlas.AddFile(name, file)
|
||||
if err != nil {
|
||||
log.Printf("WARN: InitWorldTextureAtlas: img %s failed to decode: %s", name, err)
|
||||
}
|
||||
}
|
||||
|
||||
WorldTextureAtlas.BuildTexture( /*false*/ )
|
||||
}
|
||||
Reference in New Issue
Block a user