]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove deprecated things from the maketex script
authorMikko Rasa <tdb@tdb.fi>
Mon, 12 Apr 2021 21:40:10 +0000 (00:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 12 Apr 2021 22:24:30 +0000 (01:24 +0300)
scripts/makefont.py
scripts/maketex.py

index e129c9da4c678fb09d0ca72fe091c3f241804528..aab4e19da83b6074f9f3430148dee0673c54eade 100755 (executable)
@@ -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")
 
index 916ce747c404f8b26210078a0e07b7d53f8b5fbf..57380c0b7a5ef11b1fa4c3883bc594a38cddc6f9 100755 (executable)
@@ -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))