From 249833947ff691dd79453c4d817387a6922236d6 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 22 Aug 2022 11:38:26 -0500 Subject: add element buffers --- src/gl/data.c | 72 +++++++++++++++++++++++++++++--------------------------- src/gl/drawing.c | 11 +++++++++ src/gl/gl.c | 3 ++- 3 files changed, 50 insertions(+), 36 deletions(-) (limited to 'src/gl') diff --git a/src/gl/data.c b/src/gl/data.c index f598784..777689a 100644 --- a/src/gl/data.c +++ b/src/gl/data.c @@ -65,48 +65,50 @@ int gl_bind_buffer(lua_State *L) } +#define GET_BUFFER_TYPE(type, name, conversion) \ + void * get_buffer_ ## name (lua_State *L, size_t *sz, int tbl) { \ + size_t len = lua_objlen(L, tbl); \ + *sz = len * sizeof(type); \ + type *buf = malloc(*sz); \ + if (buf == NULL) \ + hs_throw_error(L, "failed to allocate intermediary buffer"); \ + for (int i=0; i