summaryrefslogtreecommitdiff
path: root/src/opengl
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-24 17:10:50 -0500
committersanine <sanine.not@pm.me>2023-03-24 17:10:50 -0500
commit3ecb029fedcf03d3d9eec193d91d1ed1bc6dc130 (patch)
tree61637dd67e63f83c8c019cf8cfe20c503bf9fbb2 /src/opengl
parenta2fcdef91e1e839e55d0db295abe80961a8a2dc0 (diff)
add verbosity & working directory options
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/drawing.c87
-rw-r--r--src/opengl/gl.c2
2 files changed, 68 insertions, 21 deletions
diff --git a/src/opengl/drawing.c b/src/opengl/drawing.c
index eeb0496..cdab5ae 100644
--- a/src/opengl/drawing.c
+++ b/src/opengl/drawing.c
@@ -4,24 +4,30 @@
#include <lauxlib.h>
#include "util/util.h"
-int gl_set_viewport(lua_State *L);
-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);
+#define GL_DRAWING_FUNCTIONS \
+ X("ClearColor", glClearColor_bind) \
+ X("Clear", glClear_bind) \
+ X("DrawArrays", glDrawArrays_bind) \
+ X("DrawElements", glDrawElements_bind) \
+ X("Viewport", glViewport_bind) \
+ X("GenFramebuffers", glGenFramebuffers_bind) \
+ X("BindFramebuffer", glBindFramebuffer_bind) \
+ X("FramebufferTexture2D", glFramebufferTexture2D_bind) \
+ X("CullFace", glCullFace_bind) \
+ X("BlendFunc", glBlendFunc_bind) \
+
+
+#define X(name, func) int func(lua_State *L);
+GL_DRAWING_FUNCTIONS
+#undef X
void setup_drawing(lua_State *L, int gl_index)
{
struct honey_tbl_t tbl[] = {
/* functions */
- 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),
+ #define X(name, func) H_FUNC(name, func),
+ GL_DRAWING_FUNCTIONS
+ #undef X
/******** enums ********/
/* rendering primitives */
@@ -34,6 +40,28 @@ void setup_drawing(lua_State *L, int gl_index)
H_INT("DEPTH_BUFFER_BIT", GL_DEPTH_BUFFER_BIT),
H_INT("STENCIL_BUFFER_BIT", GL_STENCIL_BUFFER_BIT),
+ H_INT("FRONT", GL_FRONT),
+ H_INT("BACK", GL_BACK),
+ H_INT("FRONT_AND_BACK", GL_FRONT_AND_BACK),
+
+ /* BlendFunc factors */
+ H_INT("ZERO", GL_ZERO),
+ H_INT("ONE", GL_ONE),
+ H_INT("SRC_COLOR", GL_SRC_COLOR),
+ H_INT("ONE_MINUS_SRC_COLOR", GL_ONE_MINUS_SRC_COLOR),
+ H_INT("DST_COLOR", GL_DST_COLOR),
+ H_INT("ONE_MINUS_DST_COLOR", GL_ONE_MINUS_DST_COLOR),
+ H_INT("SRC_ALPHA", GL_SRC_ALPHA),
+ H_INT("ONE_MINUS_SRC_ALPHA", GL_ONE_MINUS_SRC_ALPHA),
+ H_INT("DST_ALPHA", GL_DST_ALPHA),
+ H_INT("ONE_MINUS_DST_ALPHA", GL_ONE_MINUS_DST_ALPHA),
+ H_INT("CONSTANT_COLOR", GL_CONSTANT_COLOR),
+ H_INT("ONE_MINUS_CONSTANT_COLOR", GL_ONE_MINUS_CONSTANT_COLOR),
+ H_INT("CONSTANT_ALPHA", GL_CONSTANT_ALPHA),
+ H_INT("ONE_MINUS_CONSTANT_ALPHA", GL_ONE_MINUS_CONSTANT_ALPHA),
+
+ H_INT("FRAMEBUFFER", GL_FRAMEBUFFER),
+
H_END
};
create_table(L, tbl);
@@ -41,7 +69,7 @@ void setup_drawing(lua_State *L, int gl_index)
lua_pop(L, 1);
}
-int gl_set_clear_color(lua_State *L)
+int glClearColor_bind(lua_State *L)
{
lua_Number r, g, b, a;
r = luaL_checknumber(L, 1);
@@ -53,7 +81,7 @@ int gl_set_clear_color(lua_State *L)
}
-int gl_clear(lua_State *L)
+int glClear_bind(lua_State *L)
{
lua_Integer mask = luaL_checkinteger(L, 1);
glClear(mask);
@@ -61,7 +89,7 @@ int gl_clear(lua_State *L)
}
-int gl_draw_arrays(lua_State *L)
+int glDrawArrays_bind(lua_State *L)
{
lua_Integer mode, first, count;
mode = luaL_checkinteger(L, 1);
@@ -72,7 +100,7 @@ int gl_draw_arrays(lua_State *L)
}
-int gl_draw_elements(lua_State *L)
+int glDrawElements_bind(lua_State *L)
{
lua_Integer mode, count, type, offset;
mode = luaL_checkinteger(L, 1);
@@ -84,7 +112,7 @@ int gl_draw_elements(lua_State *L)
}
-int gl_set_viewport(lua_State *L)
+int glViewport_bind(lua_State *L)
{
lua_Integer x, y, w, h;
x = luaL_checkinteger(L, 1);
@@ -96,7 +124,7 @@ int gl_set_viewport(lua_State *L)
}
-int gl_gen_framebuffers(lua_State *L)
+int glGenFramebuffers_bind(lua_State *L)
{
int framebuffer;
glGenFramebuffers(1, &framebuffer);
@@ -105,7 +133,7 @@ int gl_gen_framebuffers(lua_State *L)
}
-int gl_bind_framebuffer(lua_State *L)
+int glBindFramebuffer_bind(lua_State *L)
{
int target = luaL_checkinteger(L, 1);
int framebuffer = luaL_checkinteger(L, 2);
@@ -114,7 +142,7 @@ int gl_bind_framebuffer(lua_State *L)
}
-int gl_framebuffer_texture_2d(lua_State *L)
+int glFramebufferTexture2D_bind(lua_State *L)
{
int target = luaL_checkinteger(L, 1);
int attachment = luaL_checkinteger(L, 2);
@@ -125,3 +153,20 @@ int gl_framebuffer_texture_2d(lua_State *L)
glFramebufferTexture2D(target, attachment, textarget, texture, level);
return 0;
}
+
+
+int glCullFace_bind(lua_State *L)
+{
+ int mode = luaL_checkinteger(L, 1);
+ glCullFace(mode);
+ return 0;
+}
+
+
+int glBlendFunc_bind(lua_State *L)
+{
+ int sfactor = luaL_checkinteger(L, 1);
+ int dfactor = luaL_checkinteger(L, 1);
+ glBlendFunc(sfactor, dfactor);
+ return 0;
+}
diff --git a/src/opengl/gl.c b/src/opengl/gl.c
index 6643f5f..bbbb07d 100644
--- a/src/opengl/gl.c
+++ b/src/opengl/gl.c
@@ -48,6 +48,8 @@ void setup_gl(lua_State *L, int honey_index)
/* opengl capabilities */
H_INT("DEPTH_TEST", GL_DEPTH_TEST),
H_INT("CULL_FACE", GL_CULL_FACE),
+ H_INT("BLEND", GL_BLEND),
+ H_INT("SCISSOR_TEST", GL_SCISSOR_TEST),
/* strings */
H_INT("VENDOR", GL_VENDOR),