summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-23 00:31:14 -0500
committersanine <sanine.not@pm.me>2022-08-23 00:31:14 -0500
commit711f530f7afe3358c674cf418ee067e7a4501699 (patch)
tree44419df0e5f1e81a8c6cadfc1a53e4f6c0bec94f
parentc52e1b30391d730cd6d20f65ec75d61884355c5c (diff)
add gl.TexParameteri()
-rw-r--r--demo/gl-window0
-rw-r--r--demo/honey.lua6
-rw-r--r--src/gl/texture.c24
3 files changed, 30 insertions, 0 deletions
diff --git a/demo/gl-window b/demo/gl-window
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/demo/gl-window
diff --git a/demo/honey.lua b/demo/honey.lua
index b0b3ec4..3388b52 100644
--- a/demo/honey.lua
+++ b/demo/honey.lua
@@ -121,6 +121,12 @@ gl.EnableVertexAttribArray(2)
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('container.jpg', 3)
gl.TexImage2D(
gl.TEXTURE_2D, 0,
diff --git a/src/gl/texture.c b/src/gl/texture.c
index 739dd13..f9a65b3 100644
--- a/src/gl/texture.c
+++ b/src/gl/texture.c
@@ -10,6 +10,7 @@ int gl_texture_bind(lua_State *L);
int gl_texture_image_2d(lua_State *L);
int gl_texture_generate_mipmaps(lua_State *L);
int gl_texture_set_active(lua_State *L);
+int gl_tex_parameter_i(lua_State *L);
void setup_texture(lua_State *L, int gl_index)
@@ -21,6 +22,7 @@ void setup_texture(lua_State *L, int gl_index)
hs_str_cfunc("TexImage2D", gl_texture_image_2d),
hs_str_cfunc("GenerateMipmap", gl_texture_generate_mipmaps),
hs_str_cfunc("ActiveTexture", gl_texture_set_active),
+ hs_str_cfunc("TexParameteri", gl_tex_parameter_i),
/******** enums ********/
/* texture binding targets */
@@ -29,6 +31,19 @@ void setup_texture(lua_State *L, int gl_index)
/* texture data formats */
hs_str_int("RGB", GL_RGB),
hs_str_int("RGBA", GL_RGBA),
+
+ /* texture parameters */
+ hs_str_int("TEXTURE_WRAP_S", GL_TEXTURE_WRAP_S),
+ hs_str_int("TEXTURE_WRAP_T", GL_TEXTURE_WRAP_T),
+ hs_str_int("TEXTURE_MIN_FILTER", GL_TEXTURE_MIN_FILTER),
+ hs_str_int("TEXTURE_MAG_FILTER", GL_TEXTURE_MAG_FILTER),
+
+ /* wrapping types */
+ hs_str_int("REPEAT", GL_REPEAT),
+
+ /* filter types */
+ hs_str_int("NEAREST", GL_NEAREST),
+ hs_str_int("LINEAR", GL_LINEAR),
);
append_table(L, gl_index, tbl);
@@ -90,3 +105,12 @@ int gl_texture_set_active(lua_State *L)
glActiveTexture(GL_TEXTURE0 + unit);
return 0;
}
+
+
+int gl_tex_parameter_i(lua_State *L)
+{
+ lua_Integer target, pname, param;
+ hs_parse_args(L, hs_int(target), hs_int(pname), hs_int(param));
+ glTexParameteri(target, pname, param);
+ return 0;
+}