summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glslview.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/glslview.c b/glslview.c
index 6918fa0..fd0b180 100644
--- a/glslview.c
+++ b/glslview.c
@@ -22,14 +22,9 @@
#include <SDL2/SDL_opengl.h>
-#ifdef GLSLWRITE
-
-static unsigned frame_time = 0;
-
-#else
+#ifndef GLSLWRITE
static float speed = 1.0;
-static float current_time = 0;
static unsigned previous_ticks = 0;
#ifdef USE_INOTIFY
@@ -41,6 +36,7 @@ static int inotify_watch = -1;
static char *filename;
+static float current_time = 0;
static GLint time_loc;
static GLint res_loc;
@@ -177,7 +173,7 @@ static void savePNG(int width, int height, const char *output_dir) {
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, pixels);
char filename[strlen(output_dir) + 20];
- snprintf(filename, sizeof(filename), "%s/%010u.png", output_dir, frame_time);
+ snprintf(filename, sizeof(filename), "%s/%010u.png", output_dir, (unsigned)current_time);
FILE *f = fopen(filename, "wb");
if (!f) {
@@ -224,20 +220,13 @@ static void savePNG(int width, int height, const char *output_dir) {
static void render(int width, int height) {
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
-#ifdef GLSLWRITE
-
- glUniform1f(time_loc, frame_time);
-
-#else
-
+#ifndef GLSLWRITE
unsigned ticks = SDL_GetTicks();
current_time += speed * (ticks - previous_ticks);
previous_ticks = ticks;
-
- glUniform1f(time_loc, current_time);
-
#endif
+ glUniform1f(time_loc, current_time);
glUniform2f(res_loc, width, height);
glBegin(GL_QUADS);
@@ -246,10 +235,6 @@ static void render(int width, int height) {
glVertex2f(1, 1);
glVertex2f(-1, 1);
glEnd();
-
-#ifdef GLSLWRITE
- frame_time += 20;
-#endif
}
#ifndef GLSLWRITE
@@ -347,6 +332,7 @@ int main(int argc, char *argv[]) {
#ifdef GLSLWRITE
savePNG(width, height, argv[2]);
+ current_time += 20;
#endif
}