summaryrefslogtreecommitdiff
path: root/honey/init.lua
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-03-22 12:46:23 -0500
committersanine-a <sanine.not@pm.me>2023-03-22 12:46:23 -0500
commit92803015adf19848c3f3a30caea889006ad05999 (patch)
treed3a3a325664ebb3f2b8c214217dce31746a1ae9a /honey/init.lua
parent16bcc6daab84373cac0f4125c1580d3cb1261baf (diff)
tidy up main.lua
Diffstat (limited to 'honey/init.lua')
-rw-r--r--honey/init.lua22
1 files changed, 18 insertions, 4 deletions
diff --git a/honey/init.lua b/honey/init.lua
index c3dda37..6afa324 100644
--- a/honey/init.lua
+++ b/honey/init.lua
@@ -2,9 +2,9 @@ local glfw = honey.glfw
local gl = honey.gl
local window = require 'honey.window'
-local hinit = {}
-setmetatable(hinit, {__index=_G})
-setfenv(1, hinit)
+local module = {}
+setmetatable(module, {__index=_G})
+setfenv(1, module)
function init(width, height, title)
@@ -16,14 +16,28 @@ function init(width, height, title)
local window = honey.Window(width, height, title)
glfw.MakeContextCurrent(window.win)
gl.InitGlad()
+ gl.Enable(gl.DEPTH_TEST)
return window
end
+function loop(window, update)
+ local prevTime = 0
+ while not window:shouldClose() do
+ local time = glfw.GetTime()
+ local dt = time - prevTime
+ prevTime = time
+ update(dt)
+ window:swapBuffers()
+ glfw.PollEvents()
+ end
+end
+
+
function terminate()
glfw.Terminate()
end
-return hinit
+return module