summaryrefslogtreecommitdiff
path: root/honey/mesh.lua
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-03-28 16:35:22 -0500
committersanine-a <sanine.not@pm.me>2023-03-28 16:35:22 -0500
commit45dbe47d17303050cbea7c2c51e838acfe21c2fb (patch)
treec2827c7aae6cf29286766209af942f16f91ee4c8 /honey/mesh.lua
parentd1c2a881f55b80603f6a7772a2c32394d23e795a (diff)
add cached mesh loading
Diffstat (limited to 'honey/mesh.lua')
-rw-r--r--honey/mesh.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/honey/mesh.lua b/honey/mesh.lua
index 430d5c3..e46c399 100644
--- a/honey/mesh.lua
+++ b/honey/mesh.lua
@@ -1,7 +1,7 @@
-local mesh = {}
+local module = {}
local gl = honey.gl
-setmetatable(mesh, {__index=_G})
-setfenv(1, mesh)
+setmetatable(module, {__index=_G})
+setfenv(1, module)
local function insertVertex(vertices, attrib, vertex)
@@ -54,6 +54,15 @@ function loadFile(filename)
end
+local meshCache = {}
+function loadMesh(filename, index)
+ if not meshCache[filename] then
+ meshCache[filename] = loadFile(filename)
+ end
+ return meshCache[filename][index]
+end
+
+
Mesh = {}
Mesh.__index = Mesh
@@ -92,4 +101,4 @@ function Mesh.drawElements(self)
end
-return mesh
+return module