d1ceecd0ec1f7d308d99d41ca343343c6d07315d
[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 f=
12 case "$tool" in
13         compressonator)
14                 case "$format" in
15                         dxt1) f="+fourCC DXT1" ;;
16                         dxt3) f="+fourCC DXT3" ;;
17                         dxt5) f="+fourCC DXT5" ;;
18                 esac
19                 echo ">> $f ($format)"
20                 dir=`mktemp -d "$HOME/.wine/drive_c/compressonator.XXXXXX"`
21                 dir_dos="C:/${dir##*/}"
22                 ext=${src##*.}
23                 cp "$src" "$dir/src.$ext"
24                 wine "$HOME/.wine/drive_c/Program Files/AMD/The Compressonator 1.50/TheCompressonator.exe" -convert -mipmaps "$dir_dos/src.$ext" "$dir_dos/dst.dds" -codec DXTC.dll $f "$@"
25                 mv "$dir/dst.dds" "$dst"
26                 rm -rf "$dir"
27                 ;;
28         nvcompress)
29                 case "$format" in
30                         dxt1) f="-bc1" ;;
31                         dxt3) f="-alpha -bc3" ;;
32                         dxt5) f="-alpha -bc5" ;;
33                 esac
34                 nvcompress $f "$@" "$src" "$dst"
35                 ;;
36 esac