another typo fix :P
[xonotic/xonotic.git] / misc / tools / compress-texture
1 #!/bin/sh
2
3 # usage: compress-texture tool compression in.png out.dds
4 # example: compress-texture compressonator dxt1 foo.jpg foo.dds
5
6 tool=$1; shift
7 format=$1; shift
8 src=$1; shift
9 dst=$1; shift
10
11 c=
12 f=
13 case "$tool" in
14         compressonator-dxtc|compressonator-atic)
15                 case "$tool" in
16                         *-dxtc) c="-codec DXTC.dll" ;;
17                         *-atic) c="-codec ATICompressor.dll" ;;
18                 esac
19                 case "$format" in
20                         dxt1) f="+fourCC DXT1" ;;
21                         dxt3) f="+fourCC DXT3" ;;
22                         dxt5) f="+fourCC DXT5" ;;
23                 esac
24                 dir=`mktemp -d "$HOME/.wine/drive_c/compressonator.XXXXXX"`
25                 dir_dos="C:/${dir##*/}"
26                 ext=${src##*.}
27                 cp "$src" "$dir/src.$ext"
28                 wine "$HOME/.wine/drive_c/Program Files/AMD/The Compressonator 1.50/TheCompressonator.exe" -convert -mipmaps "$dir_dos/src.$ext" "$dir_dos/dst.dds" $c $f "$@" -mipper BoxFilter.dll
29                 mv "$dir/dst.dds" "$dst"
30                 rm -rf "$dir"
31                 ;;
32         nvcompress)
33                 case "$format" in
34                         dxt1) f="-bc1" ;;
35                         dxt3) f="-alpha -bc3" ;;
36                         dxt5) f="-alpha -bc5" ;;
37                 esac
38                 nvcompress $f "$@" "$src" "$dst"
39                 ;;
40 esac