Initial commit

This commit is contained in:
2022-01-20 21:58:50 +08:00
commit b44d41ec66
86 changed files with 5415 additions and 0 deletions

43
internal/asset/texture.go Normal file
View 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*/ )
}