From 9c8d5d82b6c222f8dbbe60ec0b9382bb75b52f42 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 4 Jul 2017 20:22:08 +0200 Subject: Replace a float[128][128] with a single float The whole array was incremented in lock-step so that, when values were being read, they all had the same value; so a single float can hold that value, instead of 16k copies of it. Change-Id: Ib1bd31513eb7fe9e500f16f37a1c3653426c896c Reviewed-by: hjk --- examples/svg/opengl/framebufferobject/glwidget.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/svg/opengl/framebufferobject/glwidget.cpp b/examples/svg/opengl/framebufferobject/glwidget.cpp index f7d94db..805e731 100644 --- a/examples/svg/opengl/framebufferobject/glwidget.cpp +++ b/examples/svg/opengl/framebufferobject/glwidget.cpp @@ -300,7 +300,9 @@ void GLWidget::timerEvent(QTimerEvent *) rot_z += 0.3f; rot_x += 0.1f; - static float wt[128][128]; + static float wt = 0.0; + wt += 0.1f; + const int width = logo.width(); const int dx = width >> 1, dy = dx; // disturbance point const float W = .3f; @@ -310,8 +312,7 @@ void GLWidget::timerEvent(QTimerEvent *) for (int i = 0; i < width; ++i) { for (int j = 0; j < width; ++j) { const float s = hypot(j - dx, i - dy); - wt[i][j] += 0.1f; - const double raw = AMP * sin(2 * M_PI * W * (wt[i][j] + s / v)); + const double raw = AMP * sin(2 * M_PI * W * (wt + s / v)); if (s != 0) wave[i * width + j] = raw / (0.2 * (s + 2)); else -- cgit v1.2.1