summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-13 12:29:35 -0500
committersanine <sanine.not@pm.me>2023-03-13 12:29:35 -0500
commit53b151b3fd6d4c2b953d8ed93261125577f1c123 (patch)
treef8665c90f704bdb4592e1fd413a7c7372f63b108
parent89572c1648128456822cf2dda07b13e78cfc2813 (diff)
cycle through all meshes
-rw-r--r--honey/window.lua4
-rw-r--r--main.lua31
2 files changed, 25 insertions, 10 deletions
diff --git a/honey/window.lua b/honey/window.lua
index 35e04ac..471d51e 100644
--- a/honey/window.lua
+++ b/honey/window.lua
@@ -147,6 +147,10 @@ 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)
diff --git a/main.lua b/main.lua
index 95068eb..0ff081c 100644
--- a/main.lua
+++ b/main.lua
@@ -84,16 +84,27 @@ gl.DeleteShader(vertexShader)
gl.DeleteShader(fragmentShader)
-local mesh = honey.mesh.loadFile("assets/tetrahedron.obj")[1]
---local mesh = honey.mesh.Mesh(
--- {
--- 0, 0, 0, 0, 0, 1, 0, 0,
--- 1, 0, 0, 0, 0, 1, 1, 0,
--- 0, 1, 0, 0, 0, 1, 0, 1,
--- },
--- { 0, 2, 1 }
---)
-
+local tetra = honey.mesh.loadFile("assets/tetrahedron.obj")[1]
+local cube = honey.mesh.loadFile("assets/cube.obj")[1]
+local octa = honey.mesh.loadFile("assets/octahedron.obj")[1]
+local dodeca = honey.mesh.loadFile("assets/dodecahedron.obj")[1]
+local icosa = honey.mesh.loadFile("assets/icosahedron.obj")[1]
+
+local meshes = { tetra, cube, octa, dodeca, icosa }
+local meshIndex = 1
+local mesh = meshes[1]
+
+window:setKeyCallback(function(_, key, scancode, action, mods)
+ if action ~= glfw.PRESS then return end
+
+ if key == glfw.KEY_SPACE then
+ meshIndex = meshIndex + 1
+ if meshIndex > #meshes then meshIndex = 1 end
+ mesh = meshes[meshIndex]
+ elseif key == glfw.KEY_ESCAPE then
+ window:setShouldClose(true)
+ end
+end)
while not window:shouldClose() do