summaryrefslogtreecommitdiff
path: root/src/gl/drawing.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-02 00:03:32 -0600
committersanine <sanine.not@pm.me>2023-03-02 00:03:32 -0600
commitfb0b24647350df9514c5db6f2330921f97804731 (patch)
treeb4f8962c0b2afa329b43c0a7cb5bf873bfb4f13c /src/gl/drawing.c
parentd6273ab7a5a32319e8b3631f134f2251d2474faa (diff)
remove honeysuckle
Diffstat (limited to 'src/gl/drawing.c')
-rw-r--r--src/gl/drawing.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/src/gl/drawing.c b/src/gl/drawing.c
index d772cda..eeb0496 100644
--- a/src/gl/drawing.c
+++ b/src/gl/drawing.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"
int gl_set_viewport(lua_State *L);
@@ -15,34 +15,39 @@ int gl_framebuffer_texture_2d(lua_State *L);
void setup_drawing(lua_State *L, int gl_index)
{
- int tbl = hs_create_table(L,
+ struct honey_tbl_t tbl[] = {
/* functions */
- hs_str_cfunc("DrawArrays", gl_draw_arrays),
- hs_str_cfunc("DrawElements", gl_draw_elements),
- hs_str_cfunc("ClearColor", gl_set_clear_color),
- hs_str_cfunc("Clear", gl_clear),
- hs_str_cfunc("Viewport", gl_set_viewport),
+ H_FUNC("DrawArrays", gl_draw_arrays),
+ H_FUNC("DrawElements", gl_draw_elements),
+ H_FUNC("ClearColor", gl_set_clear_color),
+ H_FUNC("Clear", gl_clear),
+ H_FUNC("Viewport", gl_set_viewport),
/******** enums ********/
/* rendering primitives */
- hs_str_int("POINTS", GL_POINTS),
- hs_str_int("LINES", GL_LINES),
- hs_str_int("TRIANGLES", GL_TRIANGLES),
+ H_INT("POINTS", GL_POINTS),
+ H_INT("LINES", GL_LINES),
+ H_INT("TRIANGLES", GL_TRIANGLES),
/* clear bitmasks */
- hs_str_int("COLOR_BUFFER_BIT", GL_COLOR_BUFFER_BIT),
- hs_str_int("DEPTH_BUFFER_BIT", GL_DEPTH_BUFFER_BIT),
- hs_str_int("STENCIL_BUFFER_BIT", GL_STENCIL_BUFFER_BIT),
- );
-
- append_table(L, gl_index, tbl);
+ H_INT("COLOR_BUFFER_BIT", GL_COLOR_BUFFER_BIT),
+ H_INT("DEPTH_BUFFER_BIT", GL_DEPTH_BUFFER_BIT),
+ H_INT("STENCIL_BUFFER_BIT", GL_STENCIL_BUFFER_BIT),
+
+ H_END
+ };
+ create_table(L, tbl);
+ append_table(L, gl_index, lua_gettop(L));
lua_pop(L, 1);
}
int gl_set_clear_color(lua_State *L)
{
lua_Number r, g, b, a;
- hs_parse_args(L, hs_num(r), hs_num(g), hs_num(b), hs_num(a));
+ r = luaL_checknumber(L, 1);
+ g = luaL_checknumber(L, 2);
+ b = luaL_checknumber(L, 3);
+ a = luaL_checknumber(L, 4);
glClearColor(r, g, b, a);
return 0;
}
@@ -50,8 +55,7 @@ int gl_set_clear_color(lua_State *L)
int gl_clear(lua_State *L)
{
- lua_Integer mask;
- hs_parse_args(L, hs_int(mask));
+ lua_Integer mask = luaL_checkinteger(L, 1);
glClear(mask);
return 0;
}
@@ -60,7 +64,9 @@ int gl_clear(lua_State *L)
int gl_draw_arrays(lua_State *L)
{
lua_Integer mode, first, count;
- hs_parse_args(L, hs_int(mode), hs_int(first), hs_int(count));
+ mode = luaL_checkinteger(L, 1);
+ first = luaL_checkinteger(L, 2);
+ count = luaL_checkinteger(L, 3);
glDrawArrays(mode, first, count);
return 0;
}
@@ -69,7 +75,10 @@ int gl_draw_arrays(lua_State *L)
int gl_draw_elements(lua_State *L)
{
lua_Integer mode, count, type, offset;
- hs_parse_args(L, hs_int(mode), hs_int(count), hs_int(type), hs_int(offset));
+ mode = luaL_checkinteger(L, 1);
+ count = luaL_checkinteger(L, 2);
+ type = luaL_checkinteger(L, 3);
+ offset = luaL_checkinteger(L, 4);
glDrawElements(mode, count, type, (const void*)offset);
return 0;
}
@@ -78,7 +87,10 @@ int gl_draw_elements(lua_State *L)
int gl_set_viewport(lua_State *L)
{
lua_Integer x, y, w, h;
- hs_parse_args(L, hs_int(x), hs_int(y), hs_int(w), hs_int(h));
+ x = luaL_checkinteger(L, 1);
+ y = luaL_checkinteger(L, 2);
+ w = luaL_checkinteger(L, 3);
+ h = luaL_checkinteger(L, 4);
glViewport(x, y, w, h);
return 0;
}