From a3e08125394897156bb1b7cbea9edc1a5aecf0f9 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 13 Apr 2021 00:40:10 +0300 Subject: [PATCH] Remove deprecated things from the maketex script --- scripts/makefont.py | 2 +- scripts/maketex.py | 25 +++++++------------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/scripts/makefont.py b/scripts/makefont.py index e129c9da..aab4e19d 100755 --- a/scripts/makefont.py +++ b/scripts/makefont.py @@ -82,7 +82,7 @@ def make_font(fn, size, ch_ranges, autohinter, margin, padding, distfield): raise Exception("Could not execute ttf2png") result = "texture\n{\n" - result += maketex.make_tex("makefont-tmp.png", wrap="CLAMP_TO_EDGE") + result += maketex.make_tex("makefont-tmp.png") result += "};\n" result += convert_def("makefont-tmp.def") diff --git a/scripts/maketex.py b/scripts/maketex.py index 916ce747..57380c0b 100755 --- a/scripts/maketex.py +++ b/scripts/maketex.py @@ -13,33 +13,28 @@ def escape(str): result += c return result -def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None, srgb=False): +def make_tex(fn, mipmap=False, srgb=False): from PIL import Image img = Image.open(fn) fmt = "".join(img.getbands()) if fmt=="LA": - fmt = "LUMINANCE_ALPHA" + fmt = "LUMINANCE8_ALPHA8" elif fmt=="L": - fmt = "LUMINANCE" + fmt = "LUMINANCE8" if srgb: fmt = "S"+fmt result = "storage {} {} {};\n".format(fmt, img.size[0], img.size[1]) - result += "filter {};\n".format(filter) - if "MIPMAP" in filter: + if mipmap: result += "generate_mipmap true;\n" - if anisotropy: - result += "max_anisotropy {};\n".format(anisotropy) - if wrap: - result += "wrap {};\n".format(wrap) result += "raw_data \"" data = list(img.getdata()) for y in range(img.size[1]): i = (img.size[1]-1-y)*img.size[0] - if fmt=="LUMINANCE" or fmt=="SLUMINANCE": + if len(img.getbands())==1: result += escape("".join([chr(v) for v in data[i:i+img.size[0]]])) else: result += escape("".join(["".join([chr(v) for v in p]) for p in data[i:i+img.size[0]]])) @@ -53,20 +48,14 @@ if __name__=="__main__": parser = argparse.ArgumentParser() parser.add_argument("-o", "--output", metavar="FILE", help="Output filename") - 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("-m", "--mipmap", action="store_true", help="Enable mipmaps") parser.add_argument("--srgb", action="store_const", const=True, help="Use sRGB color space") parser.add_argument("image") args = parser.parse_args() - filter = args.filter - if filter=="MIPMAP": - filter = "LINEAR_MIPMAP_LINEAR" - out_fn = args.output if not out_fn: out_fn = os.path.splitext(args.image)[0]+".tex2d" out = open(out_fn, "w") - out.write(make_tex(args.image, filter, args.anisotropy, args.wrap, args.srgb)) + out.write(make_tex(args.image, args.mipmap, args.srgb)) -- 2.45.2