From 0d96ebc90c9740e7e66a70aa11168b11f49d220b Mon Sep 17 00:00:00 2001 From: sanine-a Date: Fri, 12 May 2023 14:10:48 -0500 Subject: run working program with refactored code --- honey/init.lua | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'honey/init.lua') 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 -- cgit v1.2.1