X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=scripts%2Fmaketex.py;h=4da7866e7593b2f3abdfae7eaaa8e4254cd193f1;hb=5a93cc603eef43617a10b76bc9c19a3272ac1d49;hp=04de1d38a57d51cc2e25c2ea16f8e5896481283a;hpb=869a1d1bcdeea9908664d3901b5b6b34634d833b;p=libs%2Fgl.git diff --git a/scripts/maketex.py b/scripts/maketex.py index 04de1d38..4da7866e 100755 --- a/scripts/maketex.py +++ b/scripts/maketex.py @@ -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))