diff options
author | sanine <sanine.not@pm.me> | 2023-03-12 00:12:39 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-03-12 00:12:39 -0600 |
commit | b2f8ef6dad8925b43b87015e2c10b12f10a2f415 (patch) | |
tree | eca64efe16963e7a861a6da551fc48a1c5acf3e3 | |
parent | 13745925df1c7ba12fb0cbe80e36fa0681a89b5e (diff) |
remove glfw binds from opengl
-rw-r--r-- | demo/fancy/main.lua | 35 | ||||
-rw-r--r-- | demo/vector/common.lua | 28 | ||||
-rw-r--r-- | demo/vector/main.lua | 6 |
3 files changed, 35 insertions, 34 deletions
diff --git a/demo/fancy/main.lua b/demo/fancy/main.lua index 54472c5..19b3239 100644 --- a/demo/fancy/main.lua +++ b/demo/fancy/main.lua @@ -1,5 +1,6 @@ local gl = honey.gl -local window = honey.window +local glfw = honey.glfw +--local window = honey.window --===== initialize audio =====-- @@ -10,23 +11,23 @@ honey.ma.engine_play_sound(engine, 'example_sound.ogg', nil) --====== initialize opengl ======-- -gl.Init() -window.setHint(window.hintType.contextVersionMajor, 3) -window.setHint(window.hintType.contextVersionMinor, 3) -window.setHint(window.hintType.openGlProfile, window.profileType.openGlCoreProfile) +glfw.Init() +--window.setHint(window.hintType.contextVersionMajor, 3) +--window.setHint(window.hintType.contextVersionMinor, 3) +--window.setHint(window.hintType.openGlProfile, window.profileType.openGlCoreProfile) --====== create window ======-- -local w = window.create(640, 480, 'hello, world!') -window.makeContextCurrent(w) +local w = glfw.CreateWindow(640, 480, 'hello, world!', glfw.monitor_NULL, glfw.window_NULL) +glfw.MakeContextCurrent(w) gl.InitGlad() gl.Enable(gl.DEPTH_TEST) -window.setFramebufferSizeCallback(w, function(_, width, height) - print(string.format("resize: (%d, %d)", width, height)) - gl.Viewport(0, 0, width, height) -end) +--window.setFramebufferSizeCallback(w, function(_, width, height) +-- print(string.format("resize: (%d, %d)", width, height)) +-- gl.Viewport(0, 0, width, height) +--end) --====== compile shaders ======-- @@ -277,8 +278,8 @@ honey.glm.perspective(math.rad(45), 800/600, 0.1, 100, projection) local transform = honey.glm.mat4_create() -while not window.shouldClose(w) do - local time = window.getTime() +while glfw.WindowShouldClose(w) == glfw.FALSE do + local time = glfw.GetTime() gl.ClearColor(0.2, 0.3, 0.3, 1.0) gl.Clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT) @@ -306,14 +307,14 @@ while not window.shouldClose(w) do gl.BindVertexArray(suzanne.vertexArr) gl.DrawElements(gl.TRIANGLES, #suzanne.indices, gl.UNSIGNED_INT, 0) - window.swapBuffers(w) - window.pollEvents() + glfw.SwapBuffers(w) + glfw.PollEvents() end --===== shut down =====-- -window.destroy(w) -gl.Terminate() +glfw.DestroyWindow(w) +glfw.Terminate() honey.ma.engine_uninit(engine) --image.surface_destroy(surface) --image.context_destroy(cr) diff --git a/demo/vector/common.lua b/demo/vector/common.lua index 7ddd487..4ae36f9 100644 --- a/demo/vector/common.lua +++ b/demo/vector/common.lua @@ -1,15 +1,15 @@ honey.run = function() local gl = honey.gl - local window = honey.window + local glfw = honey.glfw -- initialize opengl - gl.Init() - window.setHint(window.hintType.contextVersionMajor, 3) - window.setHint(window.hintType.contextVersionMinor, 3) + glfw.Init() + --window.setHint(window.hintType.contextVersionMajor, 3) + --window.setHint(window.hintType.contextVersionMinor, 3) - local win = window.create(640, 480, 'first person demo') - honey.window.win = win - window.makeContextCurrent(win) + local win = glfw.CreateWindow(640, 480, 'honey3d', glfw.monitor_NULL, glfw.window_NULL) + glfw.MakeContextCurrent(win) + glfw.win = win gl.InitGlad() gl.Enable(gl.DEPTH_TEST) @@ -17,7 +17,7 @@ honey.run = function() honey.init() end - window.setFramebufferSizeCallback(win, function(_, width, height) + glfw.SetFramebufferSizeCallback(win, function(_, width, height) if honey.windowSizeCallback then honey.windowSizeCallback(width, height) end @@ -25,13 +25,13 @@ honey.run = function() local time = 0 drawTime = 1/60 - while not window.shouldClose(win) do - local t = window.getTime() + while glfw.WindowShouldClose(win) == glfw.FALSE do + local t = glfw.GetTime() local dt = t-time time = t honey.update(dt) - window.pollEvents() + glfw.PollEvents() if time > drawTime then if honey.clearColor then @@ -46,13 +46,13 @@ honey.run = function() end gl.Clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT) honey.draw() - window.swapBuffers(win) + glfw.SwapBuffers(win) drawTime = drawTime + 1/60 end end - window.destroy(win) - gl.Terminate() + --window.destroy(win) + glfw.Terminate() end diff --git a/demo/vector/main.lua b/demo/vector/main.lua index 2b29999..28090c6 100644 --- a/demo/vector/main.lua +++ b/demo/vector/main.lua @@ -1,6 +1,6 @@ require 'common' -local window = honey.window +local glfw = honey.glfw local nvg = honey.nvg @@ -17,8 +17,8 @@ end local time = 0 local frames = 0 function honey.update(dt) - if window.getKey(window.win, window.KEY_ESCAPE) == window.PRESS then - window.setShouldClose(honey.window.win, true) + if glfw.GetKey(glfw.win, glfw.KEY_ESCAPE) == glfw.PRESS then + glfw.SetWindowShouldClose(glfw.win, true) end time = time + dt |