summaryrefslogtreecommitdiff
path: root/src/gl/texture.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gl/texture.c')
-rw-r--r--src/gl/texture.c93
1 files changed, 48 insertions, 45 deletions
diff --git a/src/gl/texture.c b/src/gl/texture.c
index 2284511..13b23c0 100644
--- a/src/gl/texture.c
+++ b/src/gl/texture.c
@@ -1,7 +1,7 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <lua.h>
-#include <honeysuckle.h>
+#include <lauxlib.h>
#include "util/util.h"
@@ -15,50 +15,52 @@ int gl_tex_parameter_i(lua_State *L);
void setup_texture(lua_State *L, int gl_index)
{
- int tbl = hs_create_table(L,
+ struct honey_tbl_t tbl[] = {
/* functions */
- hs_str_cfunc("GenTextures", gl_texture_create),
- hs_str_cfunc("BindTexture", gl_texture_bind),
- 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),
+ H_FUNC("GenTextures", gl_texture_create),
+ H_FUNC("BindTexture", gl_texture_bind),
+ H_FUNC("TexImage2D", gl_texture_image_2d),
+ H_FUNC("GenerateMipmap", gl_texture_generate_mipmaps),
+ H_FUNC("ActiveTexture", gl_texture_set_active),
+ H_FUNC("TexParameteri", gl_tex_parameter_i),
/******** enums ********/
/* texture binding targets */
- hs_str_int("TEXTURE_2D", GL_TEXTURE_2D),
+ H_INT("TEXTURE_2D", GL_TEXTURE_2D),
/* texture data formats */
- hs_str_int("RGB", GL_RGB),
- hs_str_int("RGBA", GL_RGBA),
+ H_INT("RGB", GL_RGB),
+ H_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),
- hs_str_int("TEXTURE_SWIZZLE_R", GL_TEXTURE_SWIZZLE_R),
- hs_str_int("TEXTURE_SWIZZLE_G", GL_TEXTURE_SWIZZLE_G),
- hs_str_int("TEXTURE_SWIZZLE_B", GL_TEXTURE_SWIZZLE_B),
- hs_str_int("TEXTURE_SWIZZLE_A", GL_TEXTURE_SWIZZLE_A),
+ H_INT("TEXTURE_WRAP_S", GL_TEXTURE_WRAP_S),
+ H_INT("TEXTURE_WRAP_T", GL_TEXTURE_WRAP_T),
+ H_INT("TEXTURE_MIN_FILTER", GL_TEXTURE_MIN_FILTER),
+ H_INT("TEXTURE_MAG_FILTER", GL_TEXTURE_MAG_FILTER),
+ H_INT("TEXTURE_SWIZZLE_R", GL_TEXTURE_SWIZZLE_R),
+ H_INT("TEXTURE_SWIZZLE_G", GL_TEXTURE_SWIZZLE_G),
+ H_INT("TEXTURE_SWIZZLE_B", GL_TEXTURE_SWIZZLE_B),
+ H_INT("TEXTURE_SWIZZLE_A", GL_TEXTURE_SWIZZLE_A),
/* wrapping types */
- hs_str_int("REPEAT", GL_REPEAT),
+ H_INT("REPEAT", GL_REPEAT),
/* filter types */
- hs_str_int("NEAREST", GL_NEAREST),
- hs_str_int("LINEAR", GL_LINEAR),
+ H_INT("NEAREST", GL_NEAREST),
+ H_INT("LINEAR", GL_LINEAR),
/* swizzle targets */
- hs_str_int("RED", GL_RED),
- hs_str_int("GREEN", GL_GREEN),
- hs_str_int("BLUE", GL_BLUE),
- hs_str_int("ALPHA", GL_ALPHA),
- hs_str_int("ZERO", GL_ZERO),
- hs_str_int("ONE", GL_ONE),
- );
-
- append_table(L, gl_index, tbl);
+ H_INT("RED", GL_RED),
+ H_INT("GREEN", GL_GREEN),
+ H_INT("BLUE", GL_BLUE),
+ H_INT("ALPHA", GL_ALPHA),
+ H_INT("ZERO", GL_ZERO),
+ H_INT("ONE", GL_ONE),
+
+ H_END
+ };
+ create_table(L, tbl);
+ append_table(L, gl_index, lua_gettop(L));
lua_pop(L, 1);
}
@@ -75,7 +77,8 @@ int gl_texture_create(lua_State *L)
int gl_texture_bind(lua_State *L)
{
lua_Integer target, texture;
- hs_parse_args(L, hs_int(target), hs_int(texture));
+ target = luaL_checkinteger(L, 1);
+ texture = luaL_checkinteger(L, 2);
glBindTexture(target, texture);
return 0;
}
@@ -87,14 +90,14 @@ int gl_texture_image_2d(lua_State *L)
internal_format,
width, height,
format, type;
- void *data;
- hs_parse_args(L,
- hs_int(target), hs_int(mipmap_level),
- hs_int(internal_format),
- hs_int(width), hs_int(height),
- hs_int(format), hs_int(type),
- hs_light(data)
- );
+ target = luaL_checkinteger(L, 1);
+ mipmap_level = luaL_checkinteger(L, 2);
+ internal_format = luaL_checkinteger(L, 3);
+ width = luaL_checkinteger(L, 4);
+ height = luaL_checkinteger(L, 5);
+ format = luaL_checkinteger(L, 6);
+ type = luaL_checkinteger(L, 7);
+ void *data = lua_touserdata(L, 8);
glTexImage2D(target, mipmap_level, internal_format, width, height, 0, format, type, data);
return 0;
@@ -103,8 +106,7 @@ int gl_texture_image_2d(lua_State *L)
int gl_texture_generate_mipmaps(lua_State *L)
{
- lua_Integer target;
- hs_parse_args(L, hs_int(target));
+ lua_Integer target = luaL_checkinteger(L, 1);
glGenerateMipmap(target);
return 0;
}
@@ -112,8 +114,7 @@ int gl_texture_generate_mipmaps(lua_State *L)
int gl_texture_set_active(lua_State *L)
{
- lua_Integer unit;
- hs_parse_args(L, hs_int(unit));
+ lua_Integer unit = luaL_checkinteger(L, 1);
glActiveTexture(GL_TEXTURE0 + unit);
return 0;
}
@@ -122,7 +123,9 @@ int gl_texture_set_active(lua_State *L)
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));
+ target = luaL_checkinteger(L, 1);
+ pname = luaL_checkinteger(L, 2);
+ param = luaL_checkinteger(L, 3);
glTexParameteri(target, pname, param);
return 0;
}