diff options
Diffstat (limited to 'glslview.c')
-rw-r--r-- | glslview.c | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -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; } |