shithub: atlas

ref: 530f54915ce55bec17d7580453437173efe20374
dir: /atlasc/

View raw version
#!/bin/rc
rfork e

atlas -o /tmp/atlas.off $* > /tmp/atlas

echo 'static u8int atlas_texture[] = {'
hx /tmp/atlas | awk -F'  ' '{print $2, $3}' | sed 's/ *$/,/g;s/^/	0x/g;s/ /, 0x/g'
echo '};'
echo
echo 'static struct {'
echo '	int x, y, w, h;'
echo '}atlas[] = {'
cat /tmp/atlas.off | while(a=`{read}) { echo '	['`{basename $a(1) | sed 's/\..*//g' | tr '[a-z]' '[A-Z]'}^'] = {'$a(2)^, $a(3)^, $a(4)^, $a(5)^'},' }
echo '};'

echo 'enum {' >[1=2]
cat /tmp/atlas.off | while(a=`{read}) { echo '	'`{basename $a(1) | sed 's/\..*//g' | tr '[a-z]' '[A-Z]'}^',' } >[1=2]
echo '};' >[1=2]

rm -f /tmp/atlas.off /tmp/atlas