summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-02-02 09:34:10 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-02-02 09:34:10 +0100
commit6f023066fc9712c5bbed1b0220439e304b13f10c (patch)
tree966fad09a5c216b982953ea43f1d86e2d17cd000
parentf81f0074c0db900cbc44113d457a2395d3a55fd1 (diff)
downloadglslview-6f023066fc9712c5bbed1b0220439e304b13f10c.tar
glslview-6f023066fc9712c5bbed1b0220439e304b13f10c.zip
Some more glslview/glslwrite unification
-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
}