diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1,6 +1,8 @@ #include <stdlib.h> #include <GL/glew.h> #include <GLFW/glfw3.h> +#include <sys/time.h> +#include <time.h> #include "shader.h" #include "die.h" @@ -63,10 +65,21 @@ int main(int argc, char** argv) { frag_shader(visuals_frag, visuals_frag_size) ); + // prepare uniform variables + GLint u_time = glGetUniformLocation(shader, "time"); + int time_start = time(NULL); + // main draw loop while (!glfwWindowShouldClose(window)) { glfwPollEvents(); + // set `time` uniform + struct timeval t; + gettimeofday(&t, NULL); + t.tv_sec -= time_start; + float time = t.tv_sec + (t.tv_usec / 1e6); + glUniform1f(u_time, time); + glUseProgram(shader); glDrawArrays(GL_TRIANGLES, 0, 3); |