diff options
author | sanine-a <sanine.not@pm.me> | 2023-05-12 14:10:48 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-05-12 14:10:48 -0500 |
commit | 0d96ebc90c9740e7e66a70aa11168b11f49d220b (patch) | |
tree | 758403f74f4fbcab61a228ef58e720850b3f70db /honey/init.lua | |
parent | 6036d1b5d7e0fc160637ce70595bac57ed1fcd00 (diff) |
run working program with refactored code
Diffstat (limited to 'honey/init.lua')
-rw-r--r-- | honey/init.lua | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/honey/init.lua b/honey/init.lua index d2f5279..7ceee2f 100644 --- a/honey/init.lua +++ b/honey/init.lua @@ -1,13 +1,10 @@ local glfw = honey.glfw local gl = honey.gl -local window = require 'honey.window' -local module = {} -setmetatable(module, {__index=_G}) -setfenv(1, module) +local mesh = require 'honey.asset.mesh' -function init(width, height, title) +function honey.init(width, height, title) local width = width or 640 local height = height or 480 local title = title or "honey3d" @@ -16,34 +13,29 @@ function init(width, height, title) glfw.WindowHint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE) glfw.WindowHint(glfw.CONTEXT_VERSION_MAJOR, 4) glfw.WindowHint(glfw.CONTEXT_VERSION_MINOR, 1) - local window = honey.Window(width, height, title) - glfw.MakeContextCurrent(window.win) + honey.window = glfw.CreateWindow(width, height, title, glfw.monitor_NULL, glfw.window_NULL) + glfw.MakeContextCurrent(honey.window) gl.InitGlad() gl.Enable(gl.DEPTH_TEST) honey.ode.InitODE() - honey.mesh.createBuiltins() - - return window + mesh.init() end -function loop(window, update) +function honey.loop(update) local prevTime = 0 - while not window:shouldClose() do + while glfw.WindowShouldClose(honey.window) == glfw.FALSE do local time = glfw.GetTime() local dt = time - prevTime prevTime = time update(dt) - window:swapBuffers() + glfw.SwapBuffers(honey.window) glfw.PollEvents() end end -function terminate() +function honey.terminate() glfw.Terminate() end - - -return module |