diff options
author | sanine-a <sanine.not@pm.me> | 2023-03-28 16:35:22 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-03-28 16:35:22 -0500 |
commit | 45dbe47d17303050cbea7c2c51e838acfe21c2fb (patch) | |
tree | c2827c7aae6cf29286766209af942f16f91ee4c8 /honey.bak/window.lua | |
parent | d1c2a881f55b80603f6a7772a2c32394d23e795a (diff) |
add cached mesh loading
Diffstat (limited to 'honey.bak/window.lua')
-rw-r--r-- | honey.bak/window.lua | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/honey.bak/window.lua b/honey.bak/window.lua new file mode 100644 index 0000000..fa777d0 --- /dev/null +++ b/honey.bak/window.lua @@ -0,0 +1,160 @@ +local module = {} +local glfw = honey.glfw +setmetatable(module, {__index=_G}) +setfenv(1, module) + + +Window = {} +Window.__index = Window + + +function Window.new(_, width, height, title, monitor, share) + local monitor = monitor or glfw.monitor_NULL + local share = share or glfw.window_NULL + + local self = {} + setmetatable(self, Window) + + self.win = glfw.CreateWindow(width, height, title, monitor, share) + self.__gc = honey.util.gc_canary(function() + glfw.DestroyWindow(self.win) + end) + + return self +end +setmetatable(Window, {__call=Window.new}) + + +function Window.shouldClose(self) + return glfw.WindowShouldClose(self.win) == glfw.TRUE +end +function Window.setShouldClose(self, state) + glfw.SetWindowShouldClose(self.win, state) +end + + +function Window.setTitle(self, title) + glfw.SetWindowTitle(self.win, title) +end + + +function Window.getPos(self) + return glfw.GetWindowPos(self.win) +end +function Window.setPos(self, x, y) + glfw.SetWindowPos(self.win, x, y) +end + + +function Window.getSize(self) + return glfw.GetWindowSize(self.win) +end +function Window.setSizeLimits(self, minwidth, minheight, maxwidth, maxheight) + glfw.SetWindowSizeLimits(self.win, minwidth, minheight, maxwidth, maxheight) +end +function Window.setAspectRatio(self, numerator, denominator) + glfw.SetWindowAspectRatio(self.win, numerator, denominator) +end +function Window.setSize(self, width, height) + glfw.SetWindowSize(self.win, width, height) +end + + +function Window.getFramebufferSize(self) + return glfw.GetFramebufferSize(self.win) +end +function Window.getFrameSize(self) + return glfw.GetWindowFrameSize(self.win) +end + +function Window.getContentScale(self) + return glfw.GetWindowContentScale(self.win) +end + + +function Window.getOpacity(self) + return glfw.GetWindowOpacity(self.win) +end +function Window.setOpacity(self, opacity) + return glfw.SetWindowOpacity(self.win, opacity) +end + + +function Window.iconify(self) + return glfw.IconityWindow(self.win) +end +function Window.restore(self) + return glfw.RestoreWindow(self.win) +end +function Window.maximize(self) + return glfw.MaximizeWindow(self.win) +end +function Window.show(self) + return glfw.ShowWindow(self.win) +end +function Window.hide(self) + return glfw.HideWindow(self.win) +end +function Window.focus(self) + return glfw.FocusWindow(self.win) +end +function Window.requestAttention(self) + return glfw.RequestWindowAttention(self.win) +end + + +function Window.getMonitor(self) + return glfw.GetWindowMonitor(self.win) +end +function Window.setMonitor(self, monitor, xpos, ypos, width, height, refreshRate) + return glfw.SetWindowMonitor(self.win, monitor, xpos, ypos, width, height, refreshRate) +end + + +function Window.getAttrib(self, attrib) + return glfw.GetWindowAttrib(self.win, attrib) +end +function Window.setAttrib(self, attrib, value) + return glfw.SetWindowAttrib(self.win, attrib, value) +end + + +function Window.setPositionCallback(self, cb) + return glfw.SetWindowPosCallback(self.win, cb) +end +function Window.setSizeCallback(self, cb) + return glfw.SetWindowSizeCallback(self.win, cb) +end +function Window.setCloseCallback(self, cb) + return glfw.SetWindowCloseCallback(self.win, cb) +end +function Window.setRefreshCallback(self, cb) + return glfw.SetWindowRefreshCallback(self.win, cb) +end +function Window.setFocusCallback(self, cb) + return glfw.SetWindowFocusCallback(self.win, cb) +end +function Window.setIconifyCallback(self, cb) + return glfw.SetWindowIconifyCallback(self.win, cb) +end +function Window.setMaximizeCallback(self, cb) + return glfw.SetWindowIconifyCallback(self.win, cb) +end +function Window.setFramebufferSizeCallback(self, cb) + return glfw.SetFramebufferSizeCallback(self.win, cb) +end +function Window.setContentScaleCallback(self, cb) + return glfw.SetContentScaleCallback(self.win, cb) +end + +function Window.setKeyCallback(self, cb) + return glfw.SetKeyCallback(self.win, cb) +end + + +function Window.swapBuffers(self) + glfw.SwapBuffers(self.win) +end + + +return module.Window |