summaryrefslogtreecommitdiff
path: root/honey/ecs/script.lua
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-12 15:06:13 -0500
committersanine-a <sanine.not@pm.me>2023-05-12 15:06:13 -0500
commit759db92cf135aba21f0cbd17073d2f2e294fdf4d (patch)
tree8f0c875217ef2434d898c6c8df1775340f93a986 /honey/ecs/script.lua
parent0d96ebc90c9740e7e66a70aa11168b11f49d220b (diff)
add nice builtin shaders
Diffstat (limited to 'honey/ecs/script.lua')
-rw-r--r--honey/ecs/script.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/honey/ecs/script.lua b/honey/ecs/script.lua
index 46af4fa..a9b7644 100644
--- a/honey/ecs/script.lua
+++ b/honey/ecs/script.lua
@@ -1,3 +1,5 @@
+local glfw = honey.glfw
+
local ecs = require 'honey.ecs.ecs'
local node = require 'honey.ecs.node'
@@ -27,6 +29,26 @@ dispatch = function(db, msg, data)
end
end
+--===== bind window events to script handlers =====--
+
+bindEvents = function(window, db)
+ glfw.SetFramebufferSizeCallback(window, function(w, width, height)
+ dispatch(db, "onFramebufferSize", {window=w, width=width, height=height})
+ end)
+
+ glfw.SetKeyCallback(window, function(w, key, scancode, action, mods)
+ dispatch(db, "onKey", {window=w, key=key, scancode=scancode, action=action, mods=mods})
+ end)
+
+ glfw.SetCursorPosCallback(window, function(w, xpos, ypos)
+ dispatch(db, "onCursorPos", {window=w, xpos=xpos, ypos=ypos})
+ end)
+
+ glfw.SetMouseButtonCallback(window, function(w, button, action, mods)
+ dispatch(db, "onMouseButton", {window=w, button=button, action=action, mods=mods})
+ end)
+end
+
--===== script system =====--
local script = ecs.System("script", function(db, dt, params)