summaryrefslogtreecommitdiff
path: root/src/shader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader.c')
-rw-r--r--src/shader.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/shader.c b/src/shader.c
index eefcfc2..26bb92b 100644
--- a/src/shader.c
+++ b/src/shader.c
@@ -6,6 +6,8 @@
#include "voxel.h"
#include "shader.h"
+static GLint current_program;
+
static char *read_file(const char *filename)
{
FILE *file;
@@ -136,6 +138,7 @@ failure:
void shader_bind(Shader *shader)
{
+ current_program = shader->program_id;
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -146,6 +149,7 @@ void shader_bind(Shader *shader)
void shader_unbind(void)
{
+ current_program = 0;
glDisable(GL_CULL_FACE);
glUseProgram(0);
}
@@ -165,22 +169,28 @@ GLint shader_uniform_location(Shader *shader, const char *name)
return glGetUniformLocation(shader->program_id, name);
}
-void shader_loadf(GLint location, float value)
+void shader_load_float(GLint location, float value)
{
glUniform1f(location, value);
}
-void shader_loadi(GLint location, int value)
+void shader_load_int(GLint location, int value)
{
glUniform1i(location, value);
}
-void shader_loadv3f(GLint location, vec3 value)
+void shader_load_vec3(GLint location, vec3 value)
{
glUniform3f(location, value[0], value[1], value[2]);
}
-void shader_loadm4f(GLint location, mat4 value)
+void shader_load_mat4(GLint location, mat4 value)
{
glUniformMatrix4fv(location, 1, GL_FALSE, (float *)value);
}
+
+void shader_load_ubo(GLint location, GLuint index, Uniform *uniform)
+{
+ glUniformBlockBinding(current_program, index, location);
+ glBindBufferBase(GL_UNIFORM_BUFFER, location, uniform->id);
+}