From 994ac0c108d8e0f1d1effcad5ba8b4c2d1dd9d28 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 2 Oct 2012 00:46:04 +0200 Subject: [PATCH] Hook up the vignette effect to the sample app. --- main.cpp | 14 +++++++++++++- widgets.cpp | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 569c67d..580989e 100644 --- a/main.cpp +++ b/main.cpp @@ -34,6 +34,9 @@ float gamma_theta = 0.0f, gamma_rad = 0.0f, gamma_v = 0.5f; float gain_theta = 0.0f, gain_rad = 0.0f, gain_v = 0.25f; float saturation = 1.0f; +float radius = 0.3f; +float inner_radius = 0.3f; + void update_hsv(Effect *lift_gamma_gain_effect, Effect *saturation_effect) { RGBTriplet lift(0.0f, 0.0f, 0.0f); @@ -69,6 +72,10 @@ void mouse(int x, int y) read_colorwheel(xf, yf - 0.4f, &gain_rad, &gain_theta, &gain_v); } else if (yf >= 0.6f && yf < 0.62f && xf < 0.2f) { saturation = (xf / 0.2f) * 4.0f; + } else if (yf >= 0.65f && yf < 0.67f && xf < 0.2f) { + radius = (xf / 0.2f); + } else if (yf >= 0.70f && yf < 0.72f && xf < 0.2f) { + inner_radius = (xf / 0.2f); } } @@ -167,6 +174,7 @@ int main(int argc, char **argv) chain.add_input(inout_format); Effect *lift_gamma_gain_effect = chain.add_effect(EFFECT_LIFT_GAMMA_GAIN); Effect *saturation_effect = chain.add_effect(EFFECT_SATURATION); + Effect *vignette_effect = chain.add_effect(EFFECT_VIGNETTE); chain.add_output(inout_format); chain.finalize(); @@ -242,6 +250,8 @@ int main(int argc, char **argv) ++frame; update_hsv(lift_gamma_gain_effect, saturation_effect); + vignette_effect->set_float("radius", radius); + vignette_effect->set_float("inner_radius", inner_radius); chain.render_to_screen(src_img); glReadPixels(0, 0, WIDTH, HEIGHT, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, BUFFER_OFFSET(0)); @@ -250,7 +260,9 @@ int main(int argc, char **argv) draw_hsv_wheel(0.0f, lift_rad, lift_theta, lift_v); draw_hsv_wheel(0.2f, gamma_rad, gamma_theta, gamma_v); draw_hsv_wheel(0.4f, gain_rad, gain_theta, gain_v); - draw_saturation_bar(0.6f, saturation); + draw_saturation_bar(0.6f, saturation / 4.0f); + draw_saturation_bar(0.65f, radius); + draw_saturation_bar(0.70f, inner_radius); SDL_GL_SwapBuffers(); check_error(); diff --git a/widgets.cpp b/widgets.cpp index 529212f..53b0eac 100644 --- a/widgets.cpp +++ b/widgets.cpp @@ -102,7 +102,7 @@ void draw_saturation_bar(float y, float saturation) glColor3f(0.0f, 0.0f, 0.0f); glPointSize(5.0f); glBegin(GL_POINTS); - glVertex2f(0.2f * (saturation / 4.0f) * 9.0f / 16.0f, y + 0.01f); + glVertex2f(0.2f * saturation * 9.0f / 16.0f, y + 0.01f); glEnd(); glColor3f(1.0f, 1.0f, 1.0f); -- 2.39.5