Added texture packer for automatically creating texture atlas on build.
This commit is contained in:
40
private/texture_packer/SModule
Normal file
40
private/texture_packer/SModule
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
import os
|
||||
|
||||
Import('env')
|
||||
|
||||
def _exe_name() -> str:
|
||||
if os.name == 'nt':
|
||||
return env['BIN_DIR'] + '/texture_packer.exe'
|
||||
return env['BIN_DIR'] + '/texture_packer'
|
||||
|
||||
src_files = Split("""
|
||||
main.cpp
|
||||
|
||||
packer.cpp
|
||||
""")
|
||||
|
||||
prog_packer = env.UnityProgram(
|
||||
target = env['BIN_DIR'] + '/texture_packer',
|
||||
source = src_files,
|
||||
dependencies = {
|
||||
'argparse': {},
|
||||
'mijin': {},
|
||||
'rectpack2D': {},
|
||||
'spdlog': {},
|
||||
'stb': {}
|
||||
}
|
||||
)
|
||||
env.Default(prog_packer)
|
||||
|
||||
def _pack_textures(env, target: str, source: 'list[str]'):
|
||||
cmd = env.Command(
|
||||
target = target,
|
||||
source = source,
|
||||
action = f'{_exe_name()} $TARGET $SOURCES'
|
||||
)
|
||||
# env.Depends(cmd, prog_packer)
|
||||
return cmd
|
||||
env.AddMethod(_pack_textures, 'PackTextures')
|
||||
|
||||
Return('env')
|
||||
Reference in New Issue
Block a user