summaryrefslogtreecommitdiff
path: root/demo/first_person/texture.lua
diff options
context:
space:
mode:
Diffstat (limited to 'demo/first_person/texture.lua')
-rw-r--r--demo/first_person/texture.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/demo/first_person/texture.lua b/demo/first_person/texture.lua
new file mode 100644
index 0000000..e3b041a
--- /dev/null
+++ b/demo/first_person/texture.lua
@@ -0,0 +1,35 @@
+local Texture = {}
+local gl = honey.gl
+setmetatable(Texture, {__index=_G})
+setfenv(1, Texture)
+
+
+--===== loading =====--
+
+function Load(filename)
+ local texture = gl.GenTextures()
+ gl.BindTexture(gl.TEXTURE_2D, texture)
+
+ gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
+ gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
+
+ gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
+ gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
+
+ local image, width, height = honey.image.load(filename, 3)
+ gl.TexImage2D(
+ gl.TEXTURE_2D, 0,
+ gl.RGB, width, height,
+ gl.RGB, gl.UNSIGNED_BYTE,
+ image
+ )
+ gl.GenerateMipmap(gl.TEXTURE_2D)
+ honey.image.destroy(image)
+
+ return texture
+end
+
+
+--===== fin =====--
+
+return Texture