From aeeb0c08ac1cf1604bb1659b2c13c1a1ed500848 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 15 Oct 2018 19:43:29 +0800 Subject: *misc --- bin/Jin.exe | Bin 629760 -> 549376 bytes bin/jin.exe | Bin 629760 -> 549376 bytes bin/main.lua | 4 +-- build/vc++/jin.vcxproj | 4 +-- build/vc++/libjin/libjin.vcxproj | 3 +- build/vc++/libjin/libjin.vcxproj.filters | 4 +++ tools/wrapy.py | 57 +++++++++++++++++++++++++++++++ 7 files changed, 66 insertions(+), 6 deletions(-) diff --git a/bin/Jin.exe b/bin/Jin.exe index 9cccd2b..f29d456 100644 Binary files a/bin/Jin.exe and b/bin/Jin.exe differ diff --git a/bin/jin.exe b/bin/jin.exe index 9cccd2b..f29d456 100644 Binary files a/bin/jin.exe and b/bin/jin.exe differ diff --git a/bin/main.lua b/bin/main.lua index dd5745e..6f221ac 100644 --- a/bin/main.lua +++ b/bin/main.lua @@ -6,7 +6,7 @@ local page local tf function jin.core.onLoad() shader = jin.graphics.newShaderf("font.shader") - local bitmap = jin.graphics.newBitmap("font2.png") + local bitmap = jin.graphics.newBitmap("defaultfont.png") local tfdata = jin.graphics.newTTFData("font.ttf") tf = tfdata:newTTF(13) page = tf:typeset("this is a test") @@ -33,8 +33,6 @@ end function jin.core.onDraw() jin.graphics.useShader(shader) - jin.graphics.setFont(tf) jin.graphics.print(string.format("FPS: %d\nok this is another test", fps), 0, 0) - jin.graphics.unsetFont() jin.graphics.unuseShader() end \ No newline at end of file diff --git a/build/vc++/jin.vcxproj b/build/vc++/jin.vcxproj index 98c5d38..e43d201 100644 --- a/build/vc++/jin.vcxproj +++ b/build/vc++/jin.vcxproj @@ -94,7 +94,7 @@ opengl32.lib;glu32.lib;lua51.lib;SDL2main.lib;SDL2.lib;%(AdditionalDependencies) $(SolutionDir)libs\SDL2-2.0.5\lib\x86;$(SolutionDir)libs\LuaJIT-2.0.5\src;%(AdditionalLibraryDirectories) - Console + Windows @@ -124,7 +124,7 @@ true opengl32.lib;glu32.lib;lua51.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) $(SolutionDir)libs\SDL2-2.0.5\lib\x86;$(SolutionDir)libs\LuaJIT-2.0.5\src;%(AdditionalLibraryDirectories) - Console + Windows diff --git a/build/vc++/libjin/libjin.vcxproj b/build/vc++/libjin/libjin.vcxproj index cafe7bd..b71d835 100644 --- a/build/vc++/libjin/libjin.vcxproj +++ b/build/vc++/libjin/libjin.vcxproj @@ -1,4 +1,4 @@ - + @@ -130,6 +130,7 @@ + diff --git a/build/vc++/libjin/libjin.vcxproj.filters b/build/vc++/libjin/libjin.vcxproj.filters index 3db3161..5e67e60 100644 --- a/build/vc++/libjin/libjin.vcxproj.filters +++ b/build/vc++/libjin/libjin.vcxproj.filters @@ -70,6 +70,9 @@ {be281e38-d048-40c5-a891-38703cfa9bfa} + + {086e2fe7-2366-4d52-b059-212ada075da4} + @@ -285,6 +288,7 @@ Source\Graphics + diff --git a/tools/wrapy.py b/tools/wrapy.py index e69de29..a1975ea 100644 --- a/tools/wrapy.py +++ b/tools/wrapy.py @@ -0,0 +1,57 @@ +#!/usr/bin/python2.7 +import os, sys, random, re + +def fmt(fmt, dic): + for k in dic: + fmt = fmt.replace("{%s}" % k, str(dic[k])) + return fmt + + +def makeArray(data): + i = [0] + def fn(x): + x = str(ord(x)) + "," + if i[0] + len(x) > 78: + i[0] = len(x) + x = '\n' + x + else: + i[0] += len(x) + return x + return '{' + "".join(map(fn, data)).rstrip(",") + '}' + + +def safename(filename): + return re.sub("[^a-z0-9]", "_", os.path.basename(filename).lower()) + + +def process(filenames): + if type(filenames) is str: + filenames = [filenames] + + strings = [] + + for filename in filenames: + data = open(filename, "rb").read() + strings.append( + fmt("/* {filename} */\n" +\ + "static const char {name}[] = \n{array};", + { + "filename" : os.path.basename(filename), + "name" : safename(filename), + "array" : makeArray(data), + })) + + return "/* Automatically generated; do not edit */\n\n" +\ + "\n\n".join(strings) + + +def main(): + if len(sys.argv) < 2: + print "usage: embed FILENAMES" + sys.exit(1) + + print process(sys.argv[1:]) + + +if __name__ == "__main__": + main() \ No newline at end of file -- cgit v1.1-26-g67d0