diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gl/drawing.c | 34 | ||||
-rw-r--r-- | src/gl/shader.c | 24 | ||||
-rw-r--r-- | src/image/image.c | 8 |
3 files changed, 66 insertions, 0 deletions
diff --git a/src/gl/drawing.c b/src/gl/drawing.c index e6b1e13..0d21ee8 100644 --- a/src/gl/drawing.c +++ b/src/gl/drawing.c @@ -9,6 +9,9 @@ int gl_draw_arrays(lua_State *L); int gl_draw_elements(lua_State *L); int gl_set_clear_color(lua_State *L); int gl_clear(lua_State *L); +int gl_gen_framebuffers(lua_State *L); +int gl_bind_framebuffer(lua_State *L); +int gl_framebuffer_texture_2d(lua_State *L); void setup_drawing(lua_State *L, int gl_index) { @@ -79,3 +82,34 @@ int gl_set_viewport(lua_State *L) glViewport(x, y, w, h); return 0; } + + +int gl_gen_framebuffers(lua_State *L) +{ + int framebuffer; + glGenFramebuffers(1, &framebuffer); + lua_pushinteger(L, framebuffer); + return 1; +} + + +int gl_bind_framebuffer(lua_State *L) +{ + int target = luaL_checkinteger(L, 1); + int framebuffer = luaL_checkinteger(L, 2); + glBindFramebuffer(target, framebuffer); + return 0; +} + + +int gl_framebuffer_texture_2d(lua_State *L) +{ + int target = luaL_checkinteger(L, 1); + int attachment = luaL_checkinteger(L, 2); + int textarget = luaL_checkinteger(L, 3); + int texture = luaL_checkinteger(L, 4); + int level = luaL_checkinteger(L, 5); + + glFramebufferTexture2D(target, attachment, textarget, texture, level); + return 0; +} diff --git a/src/gl/shader.c b/src/gl/shader.c index 3732aff..7ad72a1 100644 --- a/src/gl/shader.c +++ b/src/gl/shader.c @@ -16,6 +16,8 @@ int gl_program_use(lua_State *L); int gl_uniform_get_location(lua_State *L); int gl_uniform_1i(lua_State *L); +int gl_uniform_1f(lua_State *L); +int gl_uniform_3f(lua_State *L); int gl_uniform_4f(lua_State *L); int gl_uniform_matrix_4fv(lua_State *L); @@ -37,6 +39,8 @@ void setup_shader(lua_State *L, int gl_index) hs_str_cfunc("GetUniformLocation", gl_uniform_get_location), hs_str_cfunc("Uniform1i", gl_uniform_1i), + hs_str_cfunc("Uniform1f", gl_uniform_1i), + hs_str_cfunc("Uniform3f", gl_uniform_1i), hs_str_cfunc("Uniform4f", gl_uniform_4f), hs_str_cfunc("UniformMatrix4fv", gl_uniform_matrix_4fv), @@ -157,6 +161,26 @@ int gl_uniform_1i(lua_State *L) } +int gl_uniform_1f(lua_State *L) +{ + int location = luaL_checkinteger(L, 1); + double value = luaL_checknumber(L, 2); + glUniform1f(location, value); + return 0; +} + + +int gl_uniform_3f(lua_State *L) +{ + int location = luaL_checkinteger(L, 1); + double v0 = luaL_checknumber(L, 2); + double v1 = luaL_checknumber(L, 3); + double v2 = luaL_checknumber(L, 4); + glUniform3f(location, v0, v1, v2); + return 0; +} + + int gl_uniform_4f(lua_State *L) { lua_Integer location; diff --git a/src/image/image.c b/src/image/image.c index 1c747e2..13152d0 100644 --- a/src/image/image.c +++ b/src/image/image.c @@ -7,6 +7,7 @@ #include "image.h" +int empty(lua_State *L); int load_image(lua_State *L); int free_image(lua_State *L); @@ -26,6 +27,7 @@ void setup_image(lua_State *L, int honey_index) { hs_create_table(L, /* basic images */ + hs_str_cfunc("null", empty), hs_str_cfunc("load", load_image), hs_str_cfunc("destroy", free_image), @@ -56,6 +58,12 @@ void setup_image(lua_State *L, int honey_index) /* --===== basic images =====-- */ +int empty(lua_State *L) +{ + lua_pushlightuserdata(L, NULL); + return 1; +} + int load_image(lua_State *L) { char *filename; |