aboutsummaryrefslogtreecommitdiff
path: root/uniform.c
diff options
context:
space:
mode:
Diffstat (limited to 'uniform.c')
-rw-r--r--uniform.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/uniform.c b/uniform.c
index dbfd0d0..2face0a 100644
--- a/uniform.c
+++ b/uniform.c
@@ -3,40 +3,34 @@
#include <GL/glew.h>
#include "uniform.h"
+#include "consts.h"
int time_start = 0;
GLFWwindow* window = NULL;
-uniforms_t * init_uniforms(GLuint shader, GLFWwindow* _window) {
- window = _window;
+void init_uniforms() {
+ window = glfwGetCurrentContext();
time_start = time(NULL);
-
- uniforms_t * uniforms = malloc(sizeof(uniforms_t));
-
- uniforms->time = glGetUniformLocation(shader, "time");
- uniforms->window = glGetUniformLocation(shader, "window");
-
- return uniforms;
}
//! update `uniform float time`
-static void update_u_time(GLuint u_time) {
+static void update_u_time() {
struct timeval t;
gettimeofday(&t, NULL);
t.tv_sec -= time_start;
float time = t.tv_sec + (t.tv_usec / 1e6);
- glUniform1f(u_time, time);
+ glUniform1f(U_LOC_TIME, time);
}
//! update `uniform ivec2 window`
-static void update_u_window(GLuint u_window) {
+static void update_u_window() {
int width, height;
glfwGetWindowSize(window, &width, &height);
- glUniform2i(u_window, width, height);
+ glUniform2i(U_LOC_WINDOW, width, height);
}
-void update_uniforms(uniforms_t * uniforms) {
- update_u_time(uniforms->time);
- update_u_window(uniforms->window);
+void update_uniforms() {
+ update_u_time();
+ update_u_window();
}