summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/symmetry.frag7
-rw-r--r--glslview.c49
2 files changed, 54 insertions, 2 deletions
diff --git a/examples/symmetry.frag b/examples/symmetry.frag
index faebd75..f1a72ad 100644
--- a/examples/symmetry.frag
+++ b/examples/symmetry.frag
@@ -5,6 +5,9 @@ out vec4 fragColor;
uniform vec2 res;
uniform float time;
+uniform int param_l;
+uniform int param_m;
+
const float sharpness = 300;
const float PI = 3.14159265358979323846;
@@ -31,8 +34,8 @@ void main(void) {
float scene = 0;
- int n = 32;
- float k = 0;
+ int n = param_l + 32;
+ float k = param_m;
for (int i = 0; i < n; i++) {
float c = square(vec2(0.5, 0) * rot(PI/2*(4.0*i/n)) * vec2(1, 1), 0.3, -PI/2*(k*i/n + time/1500), p);
scene = abs(scene - c);
diff --git a/glslview.c b/glslview.c
index 10235c9..4061282 100644
--- a/glslview.c
+++ b/glslview.c
@@ -53,6 +53,14 @@
static float speed = 1.0;
static unsigned previous_ticks = 0;
+static GLint param_k = 0;
+static GLint param_l = 0;
+static GLint param_m = 0;
+
+static GLint param_k_loc;
+static GLint param_l_loc;
+static GLint param_m_loc;
+
#ifdef USE_INOTIFY
static int inotify_fd = -1;
static int inotify_watch = -1;
@@ -141,6 +149,12 @@ static void load(void) {
time_loc = glGetUniformLocation(program, "time");
res_loc = glGetUniformLocation(program, "res");
+#ifndef GLSLWRITE
+ param_k_loc = glGetUniformLocation(program, "param_k");
+ param_l_loc = glGetUniformLocation(program, "param_l");
+ param_m_loc = glGetUniformLocation(program, "param_m");
+#endif
+
glUseProgram(program);
free(shader);
@@ -250,6 +264,10 @@ static void render(int width, int height) {
unsigned ticks = SDL_GetTicks();
current_time += speed * (ticks - previous_ticks);
previous_ticks = ticks;
+
+ glUniform1i(param_k_loc, param_k);
+ glUniform1i(param_l_loc, param_l);
+ glUniform1i(param_m_loc, param_m);
#endif
glUniform1f(time_loc, current_time);
@@ -278,6 +296,10 @@ static void handle_input(const char *input) {
current_time = 0;
break;
+ case 'R':
+ param_k = param_l = param_m = 0;
+ break;
+
case '+':
speed *= 1.1;
break;
@@ -341,6 +363,33 @@ int main(int argc, char *argv[]) {
switch (e.type) {
case SDL_KEYDOWN:
switch (e.key.keysym.sym) {
+#ifndef GLSLWRITE
+ case SDLK_PAGEDOWN:
+ param_k++;
+ break;
+
+ case SDLK_PAGEUP:
+ param_k--;
+ break;
+
+ case SDLK_RIGHT:
+ param_l++;
+ break;
+
+ case SDLK_LEFT:
+ param_l--;
+ break;
+
+ case SDLK_DOWN:
+ param_m++;
+ break;
+
+ case SDLK_UP:
+ param_m--;
+ break;
+
+#endif
+
case SDLK_ESCAPE:
goto quit;
}