diff options
author | chai <chaifix@163.com> | 2018-09-06 20:35:03 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-09-06 20:35:03 +0800 |
commit | e8c0a474ef001caaede8e955d1f99f3d6c542e8d (patch) | |
tree | 9aa3f1213ebc5708bbaf96f1bc6f43125e228f85 /shader/main.lua | |
parent | ab354cd16eb42e897b1b1ea09c39ddfd8b8c1ab0 (diff) |
*update
Diffstat (limited to 'shader/main.lua')
-rw-r--r-- | shader/main.lua | 42 |
1 files changed, 42 insertions, 0 deletions
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 |