diff options
Diffstat (limited to 'honey/mesh.lua')
-rw-r--r-- | honey/mesh.lua | 17 |
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 |