diff options
author | sanine <sanine.not@pm.me> | 2022-10-04 14:53:08 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-10-04 14:53:08 -0500 |
commit | 6d96b0e7ea1d98e44647d0bbbba232701a7d557e (patch) | |
tree | 15fa9d310f1db5767b662fb0bb4cad8a560d3650 /demo/first_person/texture.lua | |
parent | 0c55c0e1b48de55fea401ea1b2b3f2280ef0f93c (diff) |
add first person demo
Diffstat (limited to 'demo/first_person/texture.lua')
-rw-r--r-- | demo/first_person/texture.lua | 35 |
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 |