summaryrefslogtreecommitdiff
path: root/honey/image.lua
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-05-12 01:16:46 -0500
committersanine <sanine.not@pm.me>2023-05-12 01:16:46 -0500
commit3275ae4948fd2c1bb8da780214cbb741dc3178be (patch)
tree69dbf1d5b56896e1212454e5f79daaec1d201ec1 /honey/image.lua
parent14195dac1eda9140192ca07003258715b8b0abd3 (diff)
begin refactor
Diffstat (limited to 'honey/image.lua')
-rw-r--r--honey/image.lua50
1 files changed, 0 insertions, 50 deletions
diff --git a/honey/image.lua b/honey/image.lua
deleted file mode 100644
index f074272..0000000
--- a/honey/image.lua
+++ /dev/null
@@ -1,50 +0,0 @@
-local gl = honey.gl
-
-local module = {}
-setmetatable(module, {__index=_G})
-setfenv(1, module)
-
-function Image(filename, params)
- local params = params or {}
- local data, width, height = honey.image.load(filename, 4)
- local self = {}
- self.width = width
- self.height = height
-
- self.texture = gl.GenTextures()
- gl.BindTexture(gl.TEXTURE_2D, self.texture)
- for param, value in pairs(params) do
- gl.TexParameteri(gl.TEXTURE_2D, gl[param], value)
- end
- gl.TexImage2D(
- gl.TEXTURE_2D, 0,
- gl.RGBA, width, height,
- gl.RGBA, gl.UNSIGNED_BYTE, data
- )
- gl.GenerateMipmap(gl.TEXTURE_2D)
- honey.image.destroy(data)
-
- self.__gc = honey.util.gc_canary(function()
- gl.DeleteTextures(self.texture)
- end)
-
- return self
-end
-
-
-local cache = {}
-function loadImage(filename, params)
- if not cache[filename] then
- local img = Image(filename, params)
- cache[filename] = img
- return img
- end
-
- return cache[filename]
-end
-
-function clearImageCache()
- cache = {}
-end
-
-return module