diff options
author | Andy Nichols <andy.nichols@theqtcompany.com> | 2015-07-23 15:44:26 +0200 |
---|---|---|
committer | Andy Nichols <andy.nichols@theqtcompany.com> | 2015-07-23 18:46:15 +0000 |
commit | d6771fde23c611382443217ae6bfe5b219b7160f (patch) | |
tree | 3120be2fb3b5e3f1773ce30e3f63f69f05fbc074 /src/render/io | |
parent | 9beeedfa39dffbf60944c4212b964e57602471e7 (diff) |
Enable Attribute::dump() to dump useful data
As opposed to just random data
Change-Id: I146a44bf8adfc35eb166943a6ad2d59ce323be5d
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/io')
-rw-r--r-- | src/render/io/qattribute.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/render/io/qattribute.cpp b/src/render/io/qattribute.cpp index c1329fc8c..9087c2d64 100644 --- a/src/render/io/qattribute.cpp +++ b/src/render/io/qattribute.cpp @@ -168,35 +168,39 @@ QVector<QVector2D> Attribute::asVector2D() const void Attribute::dump(int count) { Q_D(const Attribute); - char* rawBuffer = d->m_buffer->data().data(); + const char* rawBuffer = d->m_buffer->data().constData(); rawBuffer += d->m_offset; - float* fptr; - quint16* usptr; + const float* fptr; + const quint16* usptr; int stride = d->m_stride; for (int c=0; c<count; ++c) { switch (type()) { case GL_UNSIGNED_SHORT: - if (!stride) stride = sizeof(quint16); - usptr = reinterpret_cast<quint16*>(rawBuffer); + if (stride == 0) + stride = sizeof(quint16); + usptr = reinterpret_cast<const quint16*>(rawBuffer + stride * c); qCDebug(Render::Io) << c << ":u16:" << usptr[0]; break; case GL_UNSIGNED_INT: - if (!stride) stride = sizeof(quint32); - qCDebug(Render::Io) << c << ":u32:" << reinterpret_cast<quint32*>(rawBuffer)[0]; + if (stride == 0) + stride = sizeof(quint32); + qCDebug(Render::Io) << c << ":u32:" << reinterpret_cast<const quint32*>(rawBuffer + stride * c)[0]; break; case GL_FLOAT_VEC2: - if (!stride) stride = sizeof(float) * 2; - fptr = reinterpret_cast<float*>(rawBuffer); - qCDebug(Render::Io) << c << ":vec2:"<< fptr[0] << fptr[0]; + if (stride == 0) + stride = sizeof(float) * 2; + fptr = reinterpret_cast<const float*>(rawBuffer + stride * c); + qCDebug(Render::Io) << c << ":vec2:"<< fptr[0] << fptr[1]; break; case GL_FLOAT_VEC3: - if (!stride) stride = sizeof(float) * 3; - fptr = reinterpret_cast<float*>(rawBuffer); - qCDebug(Render::Io) << c << ":vec3:" << fptr[0] << fptr[0] << fptr[2]; + if (stride == 0) + stride = sizeof(float) * 3; + fptr = reinterpret_cast<const float*>(rawBuffer + stride * c); + qCDebug(Render::Io) << c << ":vec3:" << fptr[0] << fptr[1] << fptr[2]; break; default: qCDebug(Render::Io) << Q_FUNC_INFO << "unspported type:" << QString::number(type(), 16); |