]> git.tdb.fi Git - libs/gl.git/blobdiff - scripts/maketex.py
Support more ttf2png options in makefont.py
[libs/gl.git] / scripts / maketex.py
index 04de1d38a57d51cc2e25c2ea16f8e5896481283a..4da7866e7593b2f3abdfae7eaaa8e4254cd193f1 100755 (executable)
@@ -13,7 +13,7 @@ def escape(str):
                        result += c
        return result;
 
-def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None):
+def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None, srgb=False):
        import Image
 
        img = Image.open(fn)
@@ -24,6 +24,9 @@ def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None):
        elif fmt=="L":
                fmt = "LUMINANCE"
 
+       if srgb:
+               fmt = "S"+fmt
+
        result = "storage %s %d %d;\n"%(fmt, img.size[0], img.size[1])
        result += "filter %s;\n"%filter
        if "MIPMAP" in filter:
@@ -50,6 +53,7 @@ if __name__=="__main__":
        parser.add_argument("-f", "--filter", choices=["NEAREST", "LINEAR", "MIPMAP"], default="LINEAR", help="Filtering mode")
        parser.add_argument("-a", "--anisotropy", metavar="NUMBER", help="Maximum anisotropy, 0 = disable")
        parser.add_argument("-w", "--wrap", choices=["REPEAT", "CLAMP_TO_EDGE", "MIRRORED_REPEAT"], help="Wrapping mode")
+       parser.add_argument("--srgb", action="store_const", const=True, help="Use sRGB color space")
        parser.add_argument("image")
 
        args = parser.parse_args()
@@ -62,4 +66,4 @@ if __name__=="__main__":
        if not out_fn:
                out_fn = os.path.splitext(args.image)[0]+".tex2d"
        out = file(out_fn, "w")
-       out.write(make_tex(args.image, filter, args.anisotropy, args.wrap))
+       out.write(make_tex(args.image, filter, args.anisotropy, args.wrap, args.srgb))