summaryrefslogtreecommitdiff
path: root/src/gl/shader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gl/shader.c')
-rw-r--r--src/gl/shader.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gl/shader.c b/src/gl/shader.c
index 96946fe..fb64bc0 100644
--- a/src/gl/shader.c
+++ b/src/gl/shader.c
@@ -13,6 +13,9 @@ int gl_program_attach_shader(lua_State *L);
int gl_program_link(lua_State *L);
int gl_program_use(lua_State *L);
+int gl_uniform_get_location(lua_State *L);
+int gl_uniform_4f(lua_State *L);
+
void setup_shader(lua_State *L, int gl_index)
{
@@ -32,6 +35,9 @@ void setup_shader(lua_State *L, int gl_index)
hs_str_cfunc("link", gl_program_link),
hs_str_cfunc("use", gl_program_use),
+ hs_str_cfunc("getUniformLocation", gl_uniform_get_location),
+ hs_str_cfunc("uniform4f", gl_uniform_4f),
+
hs_str_tbl("type", shader_types),
);
@@ -122,3 +128,24 @@ int gl_program_use(lua_State *L)
glUseProgram(program);
return 0;
}
+
+
+int gl_uniform_get_location(lua_State *L)
+{
+ lua_Integer program;
+ char *name;
+ hs_parse_args(L, hs_int(program), hs_str(name));
+ int location = glGetUniformLocation(program, (const GLchar*)name);
+ lua_pushinteger(L, location);
+ return 1;
+}
+
+
+int gl_uniform_4f(lua_State *L)
+{
+ lua_Integer location;
+ lua_Number v0, v1, v2, v3;
+ hs_parse_args(L, hs_int(location), hs_num(v0), hs_num(v1), hs_num(v2), hs_num(v3));
+ glUniform4f(location, v0, v1, v2, v3);
+ return 0;
+}