diff options
author | sanine <sanine.not@pm.me> | 2023-03-13 12:29:35 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-03-13 12:29:35 -0500 |
commit | 53b151b3fd6d4c2b953d8ed93261125577f1c123 (patch) | |
tree | f8665c90f704bdb4592e1fd413a7c7372f63b108 /main.lua | |
parent | 89572c1648128456822cf2dda07b13e78cfc2813 (diff) |
cycle through all meshes
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 31 |
1 files changed, 21 insertions, 10 deletions
@@ -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 |