diff options
Diffstat (limited to 'bin/main.lua')
-rw-r--r-- | bin/main.lua | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/bin/main.lua b/bin/main.lua index 9139776..829deaa 100644 --- a/bin/main.lua +++ b/bin/main.lua @@ -1,34 +1,49 @@ -local shader; -local program = [[ -extern Texture img; -extern number dt; -Color effect(Color col, Texture tex, vec2 uv, vec2 screen) -{ - return Texel(img, uv); - //return vec4(1, 0, 1, 1); - //return sin(dt)*Texel(tex, uv) * Texel(img, uv); -} -]] +io.stdout:setvbuf("no") +local shader local img local img2 +local canvas +local sw, sh = jin.graphics.getSize() function jin.core.onLoad() - shader = jin.graphics.newShader(program) - img = jin.graphics.newTexture("img.png") - img2 = jin.graphics.newTexture("img2.bmp") + 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) + canvas = jin.graphics.newCanvas(200, 200) 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 + 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:sendTexture("img", img2) - shader:sendNumber("dt", dt) - jin.graphics.draw(img, 0, 0) - jin.graphics.unuseShader() + jin.graphics.bindCanvas(canvas) + -- jin.graphics.useShader(shader) + -- shader:sendNumber("iGlobalTime", dt ) + -- shader:sendVec3("iResolution", sw, sh, 1) + -- shader:sendVec4("iMouse", mx, my, mx, my) + jin.graphics.draw(img, 0, 0, 1, 1) + --jin.graphics.unuseShader() + jin.graphics.unbindCanvas() + jin.graphics.draw(canvas, 0, 0) end
\ No newline at end of file |