summaryrefslogtreecommitdiff
path: root/src/gl/texture.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-22 23:58:00 -0500
committersanine <sanine.not@pm.me>2022-08-22 23:58:00 -0500
commitc52e1b30391d730cd6d20f65ec75d61884355c5c (patch)
tree20d71816880e6fb32f5313533c89e5fc25405ffe /src/gl/texture.c
parent1f75a21851b0a0bd4bc766c458e67721dd37c9fd (diff)
refactor: rename opengl functions to match their C counterparts
Diffstat (limited to 'src/gl/texture.c')
-rw-r--r--src/gl/texture.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/gl/texture.c b/src/gl/texture.c
index d0c3a0a..739dd13 100644
--- a/src/gl/texture.c
+++ b/src/gl/texture.c
@@ -2,6 +2,7 @@
#include <GLFW/glfw3.h>
#include <lua.h>
#include <honeysuckle.h>
+#include "util/util.h"
int gl_texture_create(lua_State *L);
@@ -13,27 +14,25 @@ int gl_texture_set_active(lua_State *L);
void setup_texture(lua_State *L, int gl_index)
{
- int bind_targets = hs_create_table(L,
- hs_str_int("texture2d", GL_TEXTURE_2D),
+ int tbl = hs_create_table(L,
+ /* 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),
+
+ /******** enums ********/
+ /* texture binding targets */
+ hs_str_int("TEXTURE_2D", GL_TEXTURE_2D),
+
+ /* texture data formats */
+ hs_str_int("RGB", GL_RGB),
+ hs_str_int("RGBA", GL_RGBA),
);
- int formats = hs_create_table(L,
- hs_str_int("rgb", GL_RGB),
- hs_str_int("rgba", GL_RGBA),
- );
-
- hs_create_table(L,
- hs_str_cfunc("create", gl_texture_create),
- hs_str_cfunc("bind", gl_texture_bind),
- hs_str_cfunc("bufferImage2d", gl_texture_image_2d),
- hs_str_cfunc("generateMipmaps", gl_texture_generate_mipmaps),
- hs_str_cfunc("setActiveUnit", gl_texture_set_active),
-
- hs_str_tbl("bindTarget", bind_targets),
- hs_str_tbl("format", formats),
- );
-
- lua_setfield(L, gl_index, "texture");
+ append_table(L, gl_index, tbl);
+ lua_pop(L, 1);
}