diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/event.c | 21 | ||||
| -rw-r--r-- | src/shader.c | 6 | ||||
| -rw-r--r-- | src/state.c | 2 |
3 files changed, 24 insertions, 5 deletions
diff --git a/src/event.c b/src/event.c index 252f9d3..9d384fc 100644 --- a/src/event.c +++ b/src/event.c @@ -8,15 +8,15 @@ static void st_set_key(SDL_Keycode sym, bool value); static void st_apply_keys(State *state); static bool g_key_states[] = { - [KEY_UP] = false, - [KEY_DOWN] = false, + [KEY_UP] = false, + [KEY_DOWN] = false, [KEY_RIGHT] = false, - [KEY_LEFT] = false, + [KEY_LEFT] = false, [KEY_INC_ITERATIONS] = false, [KEY_DEC_ITERATIONS] = false, - [KEY_ZOOM_IN] = false, + [KEY_ZOOM_IN] = false, [KEY_ZOOM_OUT] = false, }; @@ -33,7 +33,18 @@ void event_handle(State *state) break; case SDL_KEYDOWN: - st_set_key(e.key.keysym.sym, true); + if (e.key.keysym.sym == SDLK_s) + state->smooth = !state->smooth; + else if (e.key.keysym.sym == SDLK_w) + state->samples += 1.0; + else if (e.key.keysym.sym == SDLK_q) + { + state->samples -= 1.0; + if (state->samples <= 0.0) + state->samples = 1.0; + } + else + st_set_key(e.key.keysym.sym, true); break; case SDL_KEYUP: diff --git a/src/shader.c b/src/shader.c index 68295ab..52c8df8 100644 --- a/src/shader.c +++ b/src/shader.c @@ -30,6 +30,8 @@ bool shader_init(Shader *shader) || (shader->location.imag_start = st_get_location(shader->id, "u_imag_start")) == -1 || (shader->location.imag_end = st_get_location(shader->id, "u_imag_end")) == -1 || (shader->location.iterations = st_get_location(shader->id, "u_iterations")) == -1 + || (shader->location.smooth = st_get_location(shader->id, "u_smooth")) == -1 + || (shader->location.samples = st_get_location(shader->id, "u_samples")) == -1 || (shader->location.texture = st_get_location(shader->id, "u_texture")) == -1) return false; return true; @@ -55,6 +57,10 @@ void shader_set_uniforms(Shader *shader, State *state) GL_CALL(glUniform1i(shader->location.iterations, state->iterations)); + GL_CALL(glUniform1i(shader->location.smooth, state->smooth)); + + GL_CALL(glUniform1f(shader->location.samples, state->samples)); + GL_CALL(glUniform1i(shader->location.texture, 0)); GL_CALL(glActiveTexture(GL_TEXTURE0)); GL_CALL(glBindTexture(GL_TEXTURE_1D, state->texture)); diff --git a/src/state.c b/src/state.c index 37eeccc..f661de6 100644 --- a/src/state.c +++ b/src/state.c @@ -55,6 +55,8 @@ bool state_init(State *state) state->imag_start = -2.0; state->imag_end = 2.0; state->running = true; + state->smooth = false; + state->samples = 1.0; return true; } |
