summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-09-06 20:35:03 +0800
committerchai <chaifix@163.com>2018-09-06 20:35:03 +0800
commite8c0a474ef001caaede8e955d1f99f3d6c542e8d (patch)
tree9aa3f1213ebc5708bbaf96f1bc6f43125e228f85
parentab354cd16eb42e897b1b1ea09c39ddfd8b8c1ab0 (diff)
*update
-rw-r--r--JGUI/JGUI.lua36
-rw-r--r--JGUI/main.lua19
-rw-r--r--drawcall/drawcall.lua1
-rw-r--r--shader/README.md0
-rw-r--r--shader/img.pngbin0 -> 442 bytes
-rw-r--r--shader/img2.bmpbin0 -> 12342 bytes
-rw-r--r--shader/intro.oggbin0 -> 1221422 bytes
-rw-r--r--shader/intro_logo.wavbin0 -> 685750 bytes
-rw-r--r--shader/main.lua42
-rw-r--r--shader/metaball.shader15
-rw-r--r--shader/music.oggbin0 -> 2121836 bytes
11 files changed, 113 insertions, 0 deletions
diff --git a/JGUI/JGUI.lua b/JGUI/JGUI.lua
new file mode 100644
index 0000000..6f82896
--- /dev/null
+++ b/JGUI/JGUI.lua
@@ -0,0 +1,36 @@
+
+-- panel
+local JGUI = {}
+
+local Widget = {
+ -- common properties
+ name, -- name
+ x, y, width, height, -- boundary
+ swallow, -- swallow event or not by default
+ -- event callbacks
+ onClick, -- clicked callback
+ onHover, -- hover callback
+ -- common functions
+ onEvent,
+}
+function Widget.onEvent(clicked, )
+
+end
+
+local Panel = {
+ widgets = {},
+}
+
+
+------------------------------------
+--
+------------------------------------
+JGUI.newButton = function()
+
+end
+
+JGUI.newPanel = function()
+
+end
+
+
diff --git a/JGUI/main.lua b/JGUI/main.lua
new file mode 100644
index 0000000..93fea92
--- /dev/null
+++ b/JGUI/main.lua
@@ -0,0 +1,19 @@
+local JGUI = require("JGUI")
+
+function jin.core.onLoad()
+
+end
+
+function jin.core.onEvent(e)
+ if e.type == "quit" then
+ jin.core.stop()
+ end
+end
+
+function jin.core.onUpdate()
+
+end
+
+function jin.core.onDraw()
+
+end
diff --git a/drawcall/drawcall.lua b/drawcall/drawcall.lua
new file mode 100644
index 0000000..f589d5e
--- /dev/null
+++ b/drawcall/drawcall.lua
@@ -0,0 +1 @@
+-- 统计每帧的drawcall
diff --git a/shader/README.md b/shader/README.md
deleted file mode 100644
index e69de29..0000000
--- a/shader/README.md
+++ /dev/null
diff --git a/shader/img.png b/shader/img.png
new file mode 100644
index 0000000..0d11f85
--- /dev/null
+++ b/shader/img.png
Binary files differ
diff --git a/shader/img2.bmp b/shader/img2.bmp
new file mode 100644
index 0000000..dc9cf95
--- /dev/null
+++ b/shader/img2.bmp
Binary files differ
diff --git a/shader/intro.ogg b/shader/intro.ogg
new file mode 100644
index 0000000..9ba4905
--- /dev/null
+++ b/shader/intro.ogg
Binary files differ
diff --git a/shader/intro_logo.wav b/shader/intro_logo.wav
new file mode 100644
index 0000000..828c423
--- /dev/null
+++ b/shader/intro_logo.wav
Binary files differ
diff --git a/shader/main.lua b/shader/main.lua
new file mode 100644
index 0000000..4629d5b
--- /dev/null
+++ b/shader/main.lua
@@ -0,0 +1,42 @@
+io.stdout:setvbuf("no")
+local shader
+local img
+local img2
+function jin.core.onLoad()
+ local str = jin.filesystem.read("metaball.shader")
+ shader = jin.graphics.newShader(str)
+ local bitmap = jin.graphics.newBitmap("img.png")
+ -- local bitmap2 = jin.graphics.newBitmap("img2.bmp")
+ img = jin.graphics.newTexture(bitmap)
+ -- img2 = jin.graphics.newTexture(bitmap2)
+end
+
+local mx, my = 0, 0
+local sw, sh = jin.graphics.getSize()
+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)
+ shader:sendNumber("feather", 1 )
+ shader:sendVec2("scaleFactor", 1, 1)
+ shader:sendVec2("distortionFactor", 1, 1)
+ jin.graphics.draw(img, mx, my, 1, 1)
+ jin.graphics.unuseShader()
+end \ No newline at end of file
diff --git a/shader/metaball.shader b/shader/metaball.shader
new file mode 100644
index 0000000..e7e344e
--- /dev/null
+++ b/shader/metaball.shader
@@ -0,0 +1,15 @@
+extern vec2 distortionFactor;
+extern vec2 scaleFactor;
+extern number feather;
+vec4 effect(vec4 color, Texture tex, vec2 uv, vec2 px) {
+ // to barrel coordinates
+ uv = uv * 2.0 - vec2(1.0);
+ // distort
+ uv *= scaleFactor;
+ uv += (uv.yx*uv.yx) * uv * (distortionFactor - 1.0);
+ number mask = (1.0 - smoothstep(1.0-feather,1.0,abs(uv.x)))
+ * (1.0 - smoothstep(1.0-feather,1.0,abs(uv.y)));
+ // to cartesian coordinates
+ uv = (uv + vec2(1.0)) / 2.0;
+ return color * Texel(tex, uv) * mask;
+} \ No newline at end of file
diff --git a/shader/music.ogg b/shader/music.ogg
new file mode 100644
index 0000000..9d44af6
--- /dev/null
+++ b/shader/music.ogg
Binary files differ