summaryrefslogtreecommitdiff
path: root/examples/svg
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-07-04 20:22:08 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2017-07-14 09:08:43 +0000
commit9c8d5d82b6c222f8dbbe60ec0b9382bb75b52f42 (patch)
tree9505f53db7ec53a75c431b8bbe90c6fa760ec1d3 /examples/svg
parent5e80f69c33f696e8c62ac74fbb9a91de61cfe65d (diff)
downloadqtsvg-9c8d5d82b6c222f8dbbe60ec0b9382bb75b52f42.tar.gz
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 <hjk@qt.io>
Diffstat (limited to 'examples/svg')
-rw-r--r--examples/svg/opengl/framebufferobject/glwidget.cpp7
1 files changed, 4 insertions, 3 deletions
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