From b1bbc998960fff2169dc5a992c47d08723472f9b Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 14 Oct 2018 22:52:40 +0800 Subject: =?UTF-8?q?*=E7=9B=B4=E6=8E=A5=E6=B8=B2=E6=9F=93=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/Jin.exe | Bin 1560576 -> 524800 bytes bin/font.png | Bin 0 -> 2780 bytes bin/font.shader | 19 +++++++++++++++++ bin/font2.png | Bin 0 -> 3349 bytes bin/jin.exe | Bin 1560576 -> 524800 bytes bin/main.lua | 59 ++++++++++++---------------------------------------- bin/metaball.shader | 24 --------------------- 7 files changed, 32 insertions(+), 70 deletions(-) create mode 100644 bin/font.png create mode 100644 bin/font.shader create mode 100644 bin/font2.png delete mode 100644 bin/metaball.shader (limited to 'bin') diff --git a/bin/Jin.exe b/bin/Jin.exe index a9da499..e30c82c 100644 Binary files a/bin/Jin.exe and b/bin/Jin.exe differ diff --git a/bin/font.png b/bin/font.png new file mode 100644 index 0000000..151b992 Binary files /dev/null and b/bin/font.png differ diff --git a/bin/font.shader b/bin/font.shader new file mode 100644 index 0000000..f35e47e --- /dev/null +++ b/bin/font.shader @@ -0,0 +1,19 @@ +#VERTEX_SHADER + +Vertex vert(Vertex v) +{ + return v; +} + +#END_VERTEX_SHADER + +#FRAGMENT_SHADER + +uniform float dt; + +Color frag(Color col, Texture tex, Vertex v) +{ + return col * texel(tex, v.uv); +} + +#END_FRAGMENT_SHADER diff --git a/bin/font2.png b/bin/font2.png new file mode 100644 index 0000000..6c9a375 Binary files /dev/null and b/bin/font2.png differ diff --git a/bin/jin.exe b/bin/jin.exe index a9da499..e30c82c 100644 Binary files a/bin/jin.exe and b/bin/jin.exe differ diff --git a/bin/main.lua b/bin/main.lua index 2a9ee22..66fd4ba 100644 --- a/bin/main.lua +++ b/bin/main.lua @@ -1,59 +1,26 @@ io.stdout:setvbuf("no") -local shader -local img -local img2 -local canvas -local sw, sh = jin.graphics.getSize() -local page -local font +local shader +local text +local page +local tf function jin.core.onLoad() - local str = jin.filesystem.read("metaball.shader") - shader = jin.graphics.newShader(str) - local w, h = 256, 240 - local bitmap = jin.graphics.newBitmap(w, h, {255, 0, 255, 255}) - local b = bitmap:clone() - bitmap = nil - local bitmap2 = jin.graphics.newBitmap("img2.bmp") - img2 = jin.graphics.newTexture(b) - img = jin.graphics.newTexture(bitmap2) - canvas = jin.graphics.newCanvas(200, 100) - - local fontdata = jin.graphics.newFontData("font.ttf") - font = fontdata:newFont(15) - local str = jin.filesystem.read("text.txt") - page = font:typeset(str, 17, 0) - fontdata = nil + local font_shader = jin.filesystem.read("font.shader") + shader = jin.graphics.newShader(font_shader) + local bitmap = jin.graphics.newBitmap("font2.png") + local tfdata = jin.graphics.newTTFData("font.ttf") + tf = tfdata:newTTF(15) + page = tf:typeset("this is a test", 16) end --- extern vec3 iResolution; --- extern number iGlobalTime; --- extern vec4 iMouse; -local mx, my = 0, 0 + function jin.core.onEvent(e) if e.type == "Quit" then jin.core.stop() end - if e.type == "KeyDown" then - if e.key == "Escape" then - jin.core.stop() - end - end - if e.type == "MouseMotion" then - -- if e.button == "left" then - mx = e.x - my = e.y - -- end - end end -local dt = 0 function jin.core.onDraw() - dt = dt + 0.1 - --jin.graphics.useShader(shader) - -- jin.graphics.unuseShader() jin.graphics.useShader(shader) - shader:sendNumber("dt", dt) - --jin.graphics.draw(canvas, 0, 0, 2, 2) - font:print(page, 0, 0) - -- jin.graphics.unuseShader() + jin.graphics.print("this is a test", tf, 10, 10, 16) + jin.graphics.unuseShader() end \ No newline at end of file diff --git a/bin/metaball.shader b/bin/metaball.shader deleted file mode 100644 index 67be889..0000000 --- a/bin/metaball.shader +++ /dev/null @@ -1,24 +0,0 @@ -#VERTEX_SHADER -uniform float dt; - -Vertex vert(Vertex v) -{ - if(v.xy.x > 3) - v.xy += vec2(100, 100) * sin(dt); - return v; -} - -#END_VERTEX_SHADER - -#FRAGMENT_SHADER - -uniform float dt; - -Color frag(Color col, Texture tex, Vertex v) -{ - vec4 c = texel(tex, v.uv) * col; - c.gb *= sin(dt); - return c; -} - -#END_FRAGMENT_SHADER -- cgit v1.1-26-g67d0