summaryrefslogtreecommitdiffstats
path: root/src/render/geometry
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-09-18 18:04:22 +0100
committerPaul Lemire <paul.lemire@kdab.com>2015-10-13 12:13:09 +0000
commitb6756277908e1d8e15dd3e35da72c42569494152 (patch)
tree237ea333015f4479f9fbafd4184b89789983a304 /src/render/geometry
parent9c1281f56317bfb8c050d0c464a5a1da1ca885bd (diff)
Final batch of file moves for now
Change-Id: I0c9e83e3142e6b083feb2cbcabcc4279de64b95b Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/geometry')
-rw-r--r--src/render/geometry/geometry.pri10
-rw-r--r--src/render/geometry/qattribute.cpp264
-rw-r--r--src/render/geometry/qattribute.h87
-rw-r--r--src/render/geometry/qattribute_p.h59
-rw-r--r--src/render/geometry/qbuffer.cpp140
-rw-r--r--src/render/geometry/qbuffer.h116
-rw-r--r--src/render/geometry/qbuffer_p.h64
-rw-r--r--src/render/geometry/qbufferfunctor.h65
-rw-r--r--src/render/geometry/qgeometryfunctor.h67
9 files changed, 871 insertions, 1 deletions
diff --git a/src/render/geometry/geometry.pri b/src/render/geometry/geometry.pri
index 81155f086..cb4baa639 100644
--- a/src/render/geometry/geometry.pri
+++ b/src/render/geometry/geometry.pri
@@ -7,16 +7,22 @@ HEADERS += \
$$PWD/geometry_p.h \
$$PWD/geometryrenderer_p.h \
$$PWD/geometryrenderermanager_p.h \
+ $$PWD/qattribute.h \
+ $$PWD/qattribute_p.h \
+ $$PWD/qbuffer.h \
+ $$PWD/qbuffer_p.h \
+ $$PWD/qbufferfunctor.h \
$$PWD/qcuboidmesh.h \
$$PWD/qcylindergeometry.h \
$$PWD/qcylindergeometry_p.h \
$$PWD/qcylindermesh.h \
$$PWD/qgeometry.h \
$$PWD/qgeometry_p.h \
+ $$PWD/qgeometryfunctor.h \
$$PWD/qgeometryrenderer.h \
$$PWD/qgeometryrenderer_p.h \
- $$PWD/qmesh_p.h \
$$PWD/qmesh.h \
+ $$PWD/qmesh_p.h \
$$PWD/qplanemesh.h \
$$PWD/qspheremesh.h \
$$PWD/qtorusmesh.h
@@ -28,6 +34,8 @@ SOURCES += \
$$PWD/geometry.cpp \
$$PWD/geometryrenderer.cpp \
$$PWD/geometryrenderermanager.cpp \
+ $$PWD/qattribute.cpp \
+ $$PWD/qbuffer.cpp \
$$PWD/qcuboidmesh.cpp \
$$PWD/qcylindergeometry.cpp \
$$PWD/qcylindermesh.cpp \
diff --git a/src/render/geometry/qattribute.cpp b/src/render/geometry/qattribute.cpp
new file mode 100644
index 000000000..09b858128
--- /dev/null
+++ b/src/render/geometry/qattribute.cpp
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qattribute.h"
+#include "qattribute_p.h"
+#include <QVector4D>
+#include <QVector3D>
+#include <QVector2D>
+#include <QVector>
+#include <Qt3DRenderer/qbuffer.h>
+#include <Qt3DRenderer/private/renderlogging_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+/*!
+ class Qt3D::AttributePrivate
+ \internal
+*/
+QAttributePrivate::QAttributePrivate()
+ : QAbstractAttributePrivate()
+{
+}
+
+QAttribute::QAttribute(QNode *parent)
+ : QAbstractAttribute(*new QAttributePrivate(), parent)
+{
+}
+
+QAttribute::QAttribute(QBuffer *buf, DataType type, uint dataSize, int count, int offset, int stride)
+ : QAbstractAttribute(*new QAttributePrivate(), buf, QString(), type, dataSize, count, offset, stride)
+{
+}
+
+QAttribute::QAttribute(QBuffer *buf, const QString &name, DataType type, uint dataSize, int count, int offset, int stride)
+ : QAbstractAttribute(*new QAttributePrivate(), buf, name, type, dataSize, count, offset, stride)
+{
+}
+
+QAttribute::~QAttribute()
+{
+ QAbstractAttribute::cleanup();
+}
+
+void QAttribute::copy(const QNode *ref)
+{
+ QAbstractAttribute::copy(ref);
+}
+
+QVector<QVector4D> QAttribute::asVector4D() const
+{
+ Q_D(const QAttribute);
+ const QByteArray buffer = d->m_buffer->data();
+ const char *rawBuffer = buffer.constData();
+ rawBuffer += d->m_byteOffset;
+ const float* fptr;
+ int stride;
+
+ switch (dataType()) {
+ case QAttribute::Float:
+ stride = sizeof(float) * dataSize();
+ break;
+
+ default:
+ qCDebug(Render::Io) << Q_FUNC_INFO << "can't convert" << dataType() << "x" << dataSize() << "to QVector3D";
+ return QVector<QVector4D>();
+ }
+
+ if (d->m_byteStride != 0)
+ stride = d->m_byteStride;
+ QVector<QVector4D> result;
+ result.resize(d->m_count);
+
+ for (uint c = 0; c < d->m_count; ++c) {
+ QVector4D v;
+ fptr = reinterpret_cast<const float*>(rawBuffer);
+
+ for (uint i = 0, m = dataSize(); i < m; ++i)
+ v[i] = fptr[i];
+
+ result[c] = v;
+ rawBuffer += stride;
+ }
+
+ return result;
+}
+
+QVector<QVector3D> QAttribute::asVector3D() const
+{
+ Q_D(const QAttribute);
+ const QByteArray buffer = d->m_buffer->data();
+ const char *rawBuffer = buffer.constData();
+ rawBuffer += d->m_byteOffset;
+ const float* fptr;
+ int stride;
+
+ switch (dataType()) {
+ case QAttribute::Float:
+ stride = sizeof(float) * dataSize();
+ break;
+
+ default:
+ qCDebug(Render::Io) << Q_FUNC_INFO << "can't convert" << dataType() << "x" << dataSize() << "to QVector3D";
+ return QVector<QVector3D>();
+ }
+
+ if (d->m_byteStride != 0)
+ stride = d->m_byteStride;
+ QVector<QVector3D> result;
+ result.resize(d->m_count);
+
+ for (uint c = 0; c < d->m_count; ++c) {
+ QVector3D v;
+ fptr = reinterpret_cast<const float*>(rawBuffer);
+
+ for (uint i = 0, m = qMin(dataSize(), 3U); i < m; ++i)
+ v[i] = fptr[i];
+
+ result[c] = v;
+ rawBuffer += stride;
+ }
+
+ return result;
+}
+
+QVector<QVector2D> QAttribute::asVector2D() const
+{
+ Q_D(const QAttribute);
+ char* rawBuffer = d->m_buffer->data().data();
+ rawBuffer += d->m_byteOffset;
+ float* fptr;
+ int stride;
+
+ switch (dataType()) {
+ case QAttribute::Float:
+ stride = sizeof(float) * dataSize();
+ break;
+
+ default:
+ qCDebug(Render::Io) << Q_FUNC_INFO << "can't convert" << dataType() << "x" << dataSize() << "to QVector3D";
+ return QVector<QVector2D>();
+ }
+
+ if (d->m_byteStride != 0)
+ stride = d->m_byteStride;
+
+ QVector<QVector2D> result;
+ result.resize(d->m_count);
+
+ for (uint c = 0; c < d->m_count; ++c) {
+ QVector2D v;
+ fptr = reinterpret_cast<float*>(rawBuffer);
+ for (uint i = 0, m = qMin(dataSize(), 2U); i < m; ++i)
+ v[i] = fptr[i];
+ result[c] = v;
+ rawBuffer += stride;
+ }
+
+ return result;
+}
+
+void QAttribute::dump(int count)
+{
+ Q_D(const QAttribute);
+ const char* rawBuffer = d->m_buffer->data().data();
+ rawBuffer += d->m_byteOffset;
+
+ const float* fptr;
+ const quint16* usptr;
+
+ int stride = d->m_byteStride;
+
+ for (int c=0; c<count; ++c) {
+ switch (dataType()) {
+ case QAttribute::UnsignedShort:
+ if (stride == 0)
+ stride = sizeof(quint16);
+ usptr = reinterpret_cast<const quint16*>(rawBuffer + stride * c);
+ qCDebug(Render::Io) << c << ":u16:" << usptr[0];
+ break;
+ case QAttribute::UnsignedInt:
+ if (stride == 0)
+ stride = sizeof(quint32);
+ qCDebug(Render::Io) << c << ":u32:" << reinterpret_cast<const quint32*>(rawBuffer + stride * c)[0];
+ break;
+ case QAttribute::Float:
+ if (stride == 0)
+ stride = sizeof(float) * dataSize();
+ fptr = reinterpret_cast<const float*>(rawBuffer + stride * c);
+ qCDebug(Render::Io) << c << QString::fromLatin1(":vec") + QString::number(dataSize()) << fptr[0] << fptr[1];
+ break;
+
+ default: qCDebug(Render::Io) << Q_FUNC_INFO << "unspported type:" << dataType();
+ }
+ }
+}
+
+QBuffer *QAttribute::buffer() const
+{
+ return static_cast<QBuffer *>(QAbstractAttribute::buffer());
+}
+
+QString QAttribute::defaultPositionAttributeName()
+{
+ return QStringLiteral("vertexPosition");
+}
+
+QString QAttribute::defaultNormalAttributeName()
+{
+ return QStringLiteral("vertexNormal");
+}
+
+QString QAttribute::defaultColorAttributeName()
+{
+ return QStringLiteral("vertexColor");
+}
+
+QString QAttribute::defaultTextureCoordinateAttributeName()
+{
+ return QStringLiteral("vertexTexCoord");
+}
+
+QString QAttribute::defaultTangentAttributeName()
+{
+ return QStringLiteral("vertexTangent");
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/geometry/qattribute.h b/src/render/geometry/qattribute.h
new file mode 100644
index 000000000..9106cbda9
--- /dev/null
+++ b/src/render/geometry/qattribute.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QATTRIBUTE_H
+#define QT3DRENDER_QATTRIBUTE_H
+
+#include <Qt3DCore/qabstractattribute.h>
+#include <Qt3DRenderer/qt3drenderer_global.h>
+#include <QtCore/QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QAttributePrivate;
+class QBuffer;
+
+class QT3DRENDERERSHARED_EXPORT QAttribute : public Qt3D::QAbstractAttribute
+{
+ Q_OBJECT
+
+public:
+ explicit QAttribute(Qt3D::QNode *parent = 0);
+ QAttribute(QBuffer *buf, DataType type, uint dataSize, int count, int offset=0, int stride = 0);
+ QAttribute(QBuffer *buf, const QString &name, DataType type, uint dataSize, int count, int offset=0, int stride = 0);
+ ~QAttribute();
+
+ QVector<QVector4D> asVector4D() const Q_DECL_OVERRIDE;
+ QVector<QVector3D> asVector3D() const Q_DECL_OVERRIDE;
+ QVector<QVector2D> asVector2D() const Q_DECL_OVERRIDE;
+
+ void dump(int count) Q_DECL_OVERRIDE;
+
+ QBuffer *buffer() const;
+
+ static QString defaultPositionAttributeName();
+ static QString defaultNormalAttributeName();
+ static QString defaultColorAttributeName();
+ static QString defaultTextureCoordinateAttributeName();
+ static QString defaultTangentAttributeName();
+
+protected:
+ void copy(const Qt3D::QNode *ref) Q_DECL_OVERRIDE;
+
+private:
+ QT3D_CLONEABLE(QAttribute)
+ Q_DECLARE_PRIVATE(QAttribute)
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QATTRIBUTE_H
diff --git a/src/render/geometry/qattribute_p.h b/src/render/geometry/qattribute_p.h
new file mode 100644
index 000000000..0e7ef390f
--- /dev/null
+++ b/src/render/geometry/qattribute_p.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QATTRIBUTE_P_H
+#define QT3DRENDER_QATTRIBUTE_P_H
+
+#include <private/qabstractattribute_p.h>
+#include <Qt3DRenderer/qt3drenderer_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QAttribute;
+
+class QT3DRENDERERSHARED_EXPORT QAttributePrivate : public Qt3D::QAbstractAttributePrivate
+{
+public:
+ QAttributePrivate();
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QATTRIBUTE_P_H
diff --git a/src/render/geometry/qbuffer.cpp b/src/render/geometry/qbuffer.cpp
new file mode 100644
index 000000000..6a86f74f7
--- /dev/null
+++ b/src/render/geometry/qbuffer.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbuffer.h"
+#include "qbuffer_p.h"
+#include <Qt3DRenderer/private/renderlogging_p.h>
+#include <Qt3DCore/qscenepropertychange.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3D;
+
+namespace Qt3DRender {
+
+/*!
+ \class Qt3D::BufferPrivate
+ \internal
+*/
+QBufferPrivate::QBufferPrivate()
+ : QAbstractBufferPrivate()
+ , m_usage(QBuffer::StaticDraw)
+{
+}
+
+
+QBuffer::QBuffer(QBuffer::BufferType ty, QNode *parent)
+ : QAbstractBuffer(*new QBufferPrivate(), parent)
+{
+ Q_D(QBuffer);
+ d->m_type = ty;
+}
+
+QBuffer::~QBuffer()
+{
+ QAbstractBuffer::cleanup();
+}
+
+/*! \internal */
+QBuffer::QBuffer(QBufferPrivate &dd, QBuffer::BufferType ty, QNode *parent)
+ : QAbstractBuffer(dd, parent)
+{
+ Q_D(QBuffer);
+ d->m_type = ty;
+}
+
+void QBuffer::copy(const QNode *ref)
+{
+ QAbstractBuffer::copy(ref);
+ const QBuffer *buffer = static_cast<const QBuffer *>(ref);
+ d_func()->m_type = buffer->d_func()->m_type;
+ d_func()->m_usage = buffer->d_func()->m_usage;
+ d_func()->m_functor = buffer->d_func()->m_functor;
+}
+
+QBuffer::UsageType QBuffer::usage() const
+{
+ Q_D(const QBuffer);
+ return d->m_usage;
+}
+
+void QBuffer::setUsage(QBuffer::UsageType usage)
+{
+ Q_D(QBuffer);
+ if (usage != d->m_usage) {
+ d->m_usage = usage;
+ emit usageChanged();
+ }
+}
+
+QBuffer::BufferType QBuffer::type() const
+{
+ Q_D(const QBuffer);
+ return d->m_type;
+}
+
+void QBuffer::setBufferFunctor(const QBufferFunctorPtr &functor)
+{
+ Q_D(QBuffer);
+ if (functor && d->m_functor && *functor == *d->m_functor)
+ return;
+ d->m_functor = functor;
+ if (d->m_changeArbiter != Q_NULLPTR) {
+ QScenePropertyChangePtr change(new QScenePropertyChange(NodeUpdated, QSceneChange::Node, id()));
+ change->setPropertyName("bufferFunctor");
+ change->setValue(QVariant::fromValue(d->m_functor));
+ d->notifyObservers(change);
+ }
+}
+
+QBufferFunctorPtr QBuffer::bufferFunctor() const
+{
+ Q_D(const QBuffer);
+ return d->m_functor;
+}
+
+void QBuffer::setType(QBuffer::BufferType type)
+{
+ Q_D(QBuffer);
+ if (type != d->m_type) {
+ d->m_type = type;
+ emit typeChanged();
+ }
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/geometry/qbuffer.h b/src/render/geometry/qbuffer.h
new file mode 100644
index 000000000..d1d9f9929
--- /dev/null
+++ b/src/render/geometry/qbuffer.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QBUFFER_H
+#define QT3DRENDER_QBUFFER_H
+
+#include <Qt3DCore/qabstractbuffer.h>
+#include <Qt3DRenderer/qt3drenderer_global.h>
+#include <QSharedPointer>
+#include <QOpenGLBuffer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+GLint elementType(GLint type);
+GLint tupleSizeFromType(GLint type);
+GLuint byteSizeFromType(GLint type);
+
+class QBufferPrivate;
+class QBufferFunctor;
+typedef QSharedPointer<QBufferFunctor> QBufferFunctorPtr;
+
+class QT3DRENDERERSHARED_EXPORT QBuffer : public Qt3D::QAbstractBuffer
+{
+ Q_OBJECT
+ Q_PROPERTY(BufferType type READ type WRITE setType NOTIFY typeChanged)
+ Q_PROPERTY(UsageType usage READ usage WRITE setUsage NOTIFY usageChanged)
+
+public:
+ enum BufferType
+ {
+ VertexBuffer = 0x8892, // GL_ARRAY_BUFFER
+ IndexBuffer = 0x8893, // GL_ELEMENT_ARRAY_BUFFER
+ PixelPackBuffer = 0x88EB, // GL_PIXEL_PACK_BUFFER
+ PixelUnpackBuffer = 0x88EC // GL_PIXEL_UNPACK_BUFFER
+ };
+ Q_ENUM(BufferType)
+
+ enum UsageType
+ {
+ StreamDraw = 0x88E0, // GL_STREAM_DRAW
+ StreamRead = 0x88E1, // GL_STREAM_READ
+ StreamCopy = 0x88E2, // GL_STREAM_COPY
+ StaticDraw = 0x88E4, // GL_STATIC_DRAW
+ StaticRead = 0x88E5, // GL_STATIC_READ
+ StaticCopy = 0x88E6, // GL_STATIC_COPY
+ DynamicDraw = 0x88E8, // GL_DYNAMIC_DRAW
+ DynamicRead = 0x88E9, // GL_DYNAMIC_READ
+ DynamicCopy = 0x88EA // GL_DYNAMIC_COPY
+ };
+ Q_ENUM(UsageType)
+
+ QBuffer(BufferType ty = QBuffer::VertexBuffer, Qt3D::QNode *parent = 0);
+ ~QBuffer();
+
+ void setUsage(UsageType usage);
+ UsageType usage() const;
+
+ void setType(BufferType type);
+ BufferType type() const;
+
+ void setBufferFunctor(const QBufferFunctorPtr &functor);
+ QBufferFunctorPtr bufferFunctor() const;
+
+protected:
+ QBuffer(QBufferPrivate &dd, QBuffer::BufferType ty, Qt3D::QNode *parent = 0);
+ void copy(const Qt3D::QNode *ref) Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void typeChanged();
+ void usageChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QBuffer)
+ QT3D_CLONEABLE(QBuffer)
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QBUFFER_H
diff --git a/src/render/geometry/qbuffer_p.h b/src/render/geometry/qbuffer_p.h
new file mode 100644
index 000000000..53bea6359
--- /dev/null
+++ b/src/render/geometry/qbuffer_p.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QBUFFER_P_H
+#define QT3DRENDER_QBUFFER_P_H
+
+#include <private/qabstractbuffer_p.h>
+#include <Qt3DRenderer/qbuffer.h>
+#include <Qt3DRenderer/qbufferfunctor.h>
+#include <Qt3DRenderer/qt3drenderer_global.h>
+#include <QOpenGLBuffer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QT3DRENDERERSHARED_EXPORT QBufferPrivate : public Qt3D::QAbstractBufferPrivate
+{
+public:
+ QBufferPrivate();
+
+ QBuffer::BufferType m_type;
+ QBuffer::UsageType m_usage;
+ QBufferFunctorPtr m_functor;
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QBUFFER_P_H
diff --git a/src/render/geometry/qbufferfunctor.h b/src/render/geometry/qbufferfunctor.h
new file mode 100644
index 000000000..4a508b975
--- /dev/null
+++ b/src/render/geometry/qbufferfunctor.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QBUFFERFUNCTOR
+#define QT3DRENDER_QBUFFERFUNCTOR
+
+#include <Qt3DRenderer/qt3drenderer_global.h>
+#include <Qt3DCore/qabstractfunctor.h>
+#include <QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QT3DRENDERERSHARED_EXPORT QBufferFunctor : public Qt3D::QAbstractFunctor
+{
+public:
+ virtual ~QBufferFunctor() {}
+ virtual QByteArray operator()() = 0;
+ virtual bool operator ==(const QBufferFunctor &other) const = 0;
+};
+
+typedef QSharedPointer<QBufferFunctor> QBufferFunctorPtr;
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Qt3DRender::QBufferFunctorPtr)
+
+#endif // QT3DRENDER_QBUFFERFUNCTOR
+
diff --git a/src/render/geometry/qgeometryfunctor.h b/src/render/geometry/qgeometryfunctor.h
new file mode 100644
index 000000000..4290fbe7b
--- /dev/null
+++ b/src/render/geometry/qgeometryfunctor.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QGEOMETRYFUNCTOR
+#define QT3DRENDER_QGEOMETRYFUNCTOR
+
+#include <Qt3DRenderer/qt3drenderer_global.h>
+#include <Qt3DCore/qabstractfunctor.h>
+#include <QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QGeometry;
+
+class QT3DRENDERERSHARED_EXPORT QGeometryFunctor : public Qt3D::QAbstractFunctor
+{
+public:
+ virtual ~QGeometryFunctor() {}
+ virtual QGeometry *operator()() = 0;
+ virtual bool operator ==(const QGeometryFunctor &other) const = 0;
+};
+
+typedef QSharedPointer<QGeometryFunctor> QGeometryFunctorPtr;
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Qt3DRender::QGeometryFunctorPtr)
+
+#endif // QT3DRENDER_QGEOMETRYFUNCTOR
+