summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/compute-particles/ParticlesScene.qml
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2016-07-11 12:04:24 +0200
committerSean Harmer <sean.harmer@kdab.com>2016-07-19 07:03:49 +0000
commit8c54e49e6a0669af1e77525e0e7071b22439d480 (patch)
tree4395f7c67818266f57c46bd4fee7e3410b33fcc9 /examples/qt3d/compute-particles/ParticlesScene.qml
parent7eaf108d53e9d37d214e56218a40220fbca94e43 (diff)
Compute-Particles: use vec4 in the ParticlesData structure
Since vec3-vec4 padding is not always correctly implemented in all OpenGL GPU implementations, use vec4 in the struct declaration. Also slightly improve readibility of the buffer construction code. Change-Id: I9dfbeb2bcdc0a713e1e0a872f6a5e8cfe50c52a3 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples/qt3d/compute-particles/ParticlesScene.qml')
-rw-r--r--examples/qt3d/compute-particles/ParticlesScene.qml9
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/qt3d/compute-particles/ParticlesScene.qml b/examples/qt3d/compute-particles/ParticlesScene.qml
index cbb21f266..e63c6cb91 100644
--- a/examples/qt3d/compute-particles/ParticlesScene.qml
+++ b/examples/qt3d/compute-particles/ParticlesScene.qml
@@ -94,12 +94,13 @@ Entity {
readonly property int floatSize: 4
function buildParticlesBuffer() {
- var bufferData = new Float32Array(particlesCount * 4 * 3);
+ var byteSizeOfParticleData = 12;
+ var bufferData = new Float32Array(particlesCount * byteSizeOfParticleData);
var factor = 500.0;
for (var i = 0; i < particlesCount; ++i) {
- var positionIdx = i * 12;
- var velocityIdx = i * 12 + 4;
- var colorIdx = i * 12 + 8;
+ var positionIdx = i * byteSizeOfParticleData;
+ var velocityIdx = i * byteSizeOfParticleData + 4;
+ var colorIdx = i * byteSizeOfParticleData + 8;
for (var j = 0; j < 3; ++j) {
bufferData[positionIdx + j] = (Math.random() - 0.5) * factor;