da050f964773a18ddc19a0b723abaa42922bcf07
[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|compressor-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                 echo ">> $f ($format)"
25                 dir=`mktemp -d "$HOME/.wine/drive_c/compressonator.XXXXXX"`
26                 dir_dos="C:/${dir##*/}"
27                 ext=${src##*.}
28                 cp "$src" "$dir/src.$ext"
29                 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 "$@"
30                 mv "$dir/dst.dds" "$dst"
31                 rm -rf "$dir"
32                 ;;
33         nvcompress)
34                 case "$format" in
35                         dxt1) f="-bc1" ;;
36                         dxt3) f="-alpha -bc3" ;;
37                         dxt5) f="-alpha -bc5" ;;
38                 esac
39                 nvcompress $f "$@" "$src" "$dst"
40                 ;;
41 esac