diff options
Diffstat (limited to 'src/quick3d/quick3drender/items')
40 files changed, 3649 insertions, 0 deletions
diff --git a/src/quick3d/quick3drender/items/items.pri b/src/quick3d/quick3drender/items/items.pri new file mode 100644 index 000000000..881923b59 --- /dev/null +++ b/src/quick3d/quick3drender/items/items.pri @@ -0,0 +1,44 @@ +HEADERS += \ + $$PWD/quick3drenderpassfilter.h \ + $$PWD/quick3drendertarget.h \ + $$PWD/quick3dtechniquefilter.h \ + $$PWD/quick3dviewport.h \ + $$PWD/quick3dmaterial.h \ + $$PWD/quick3dtechnique.h \ + $$PWD/quick3deffect.h \ + $$PWD/quick3dscene.h \ + $$PWD/shaderpropertyparser_p.h \ + $$PWD/quick3dtexture.h \ + $$PWD/quick3drenderpass.h \ + $$PWD/quick3dsortmethod.h \ + $$PWD/quick3dparameter_p.h \ + $$PWD/quick3dparameter.h \ + $$PWD/quick3dshaderdata.h \ + $$PWD/quick3dshaderdataarray.h \ + $$PWD/quick3dstateset.h \ + $$PWD/quick3drendertargetselector.h \ + $$PWD/quick3dgeometry.h \ + $$PWD/quick3dbuffer.h + +SOURCES += \ + $$PWD/quick3drenderpassfilter.cpp \ + $$PWD/quick3drendertarget.cpp \ + $$PWD/quick3dtechniquefilter.cpp \ + $$PWD/quick3dviewport.cpp \ + $$PWD/quick3dmaterial.cpp \ + $$PWD/quick3dtechnique.cpp \ + $$PWD/quick3deffect.cpp \ + $$PWD/quick3dscene.cpp \ + $$PWD/shaderpropertyparser.cpp \ + $$PWD/quick3dtexture.cpp \ + $$PWD/quick3drenderpass.cpp \ + $$PWD/quick3dsortmethod.cpp \ + $$PWD/quick3dparameter.cpp \ + $$PWD/quick3dshaderdata.cpp \ + $$PWD/quick3dshaderdataarray.cpp \ + $$PWD/quick3dstateset.cpp \ + $$PWD/quick3drendertargetselector.cpp \ + $$PWD/quick3dgeometry.cpp \ + $$PWD/quick3dbuffer.cpp + +INCLUDEPATH += $$PWD diff --git a/src/quick3d/quick3drender/items/quick3dbuffer.cpp b/src/quick3d/quick3drender/items/quick3dbuffer.cpp new file mode 100644 index 000000000..aaa3645c1 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dbuffer.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "quick3dbuffer.h" +#include <QQmlEngine> +#include <QJSValue> +#include <QtQml/private/qqmlengine_p.h> +#include <QtQml/private/qjsvalue_p.h> +#include <QtQml/private/qv4typedarray_p.h> +#include <QtQml/private/qv4arraybuffer_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +namespace Quick { + +Quick3DBuffer::Quick3DBuffer(QObject *parent) + : QObject(parent) + , m_engine(Q_NULLPTR) + , m_v4engine(Q_NULLPTR) +{ + QObject::connect(parentBuffer(), &Qt3DCore::QAbstractBuffer::dataChanged, this, &Quick3DBuffer::bufferDataChanged); +} + +QByteArray Quick3DBuffer::convertToRawData(const QJSValue &jsValue) +{ + initEngines(); + Q_ASSERT(m_v4engine); + QV4::Scope scope(m_v4engine); + QV4::Scoped<QV4::TypedArray> typedArray(scope, + QJSValuePrivate::convertedToValue(m_v4engine, jsValue)); + if (!typedArray) + return QByteArray(); + + char *dataPtr = reinterpret_cast<char *>(typedArray->arrayData()->data()); + dataPtr += typedArray->d()->byteOffset; + uint byteLength = typedArray->byteLength(); + return QByteArray::fromRawData(dataPtr, byteLength); +} + +QVariant Quick3DBuffer::bufferData() const +{ + return QVariant::fromValue(parentBuffer()->data()); +} + +void Quick3DBuffer::setBufferData(const QVariant &bufferData) +{ + QJSValue jsValue = bufferData.value<QJSValue>(); + parentBuffer()->setData(convertToRawData(jsValue)); +} + +void Quick3DBuffer::initEngines() +{ + if (m_engine == Q_NULLPTR) { + m_engine = qmlEngine(parent()); + m_v4engine = QQmlEnginePrivate::getV4Engine(m_engine); + } +} + +} // Quick + +} // Render + +} // Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dbuffer.h b/src/quick3d/quick3drender/items/quick3dbuffer.h new file mode 100644 index 000000000..edebb1454 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dbuffer.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DBUFFER_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DBUFFER_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/QBuffer> + +QT_BEGIN_NAMESPACE + +class QQmlEngine; +class QJSValue; + +namespace QV4 { +struct ExecutionEngine; +} + +namespace Qt3DRender { + +namespace Render { + +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DBuffer : public QObject +{ + Q_OBJECT + Q_PROPERTY(QVariant data READ bufferData WRITE setBufferData NOTIFY bufferDataChanged) +public: + explicit Quick3DBuffer(QObject *parent = Q_NULLPTR); + inline QBuffer *parentBuffer() const { return qobject_cast<QBuffer *>(parent()); } + + QVariant bufferData() const; + void setBufferData(const QVariant &bufferData); + +Q_SIGNALS: + void bufferDataChanged(); + +private: + QQmlEngine *m_engine; + QV4::ExecutionEngine *m_v4engine; + void initEngines(); + QByteArray convertToRawData(const QJSValue &jsValue); +}; + +} // Quick + +} // Render + +} // Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DBUFFER_H diff --git a/src/quick3d/quick3drender/items/quick3deffect.cpp b/src/quick3d/quick3drender/items/quick3deffect.cpp new file mode 100644 index 000000000..b7f6cbed6 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3deffect.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** 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 "quick3deffect.h" +#include <Qt3DRender/qeffect.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DEffect::Quick3DEffect(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QTechnique> Quick3DEffect::techniqueList() +{ + return QQmlListProperty<QTechnique>(this, 0, + &Quick3DEffect::appendTechnique, + &Quick3DEffect::techniqueCount, + &Quick3DEffect::techniqueAt, + &Quick3DEffect::clearTechniqueList); +} + +QQmlListProperty<QParameter> Quick3DEffect::parameterList() +{ + return QQmlListProperty<QParameter>(this, 0, + &Quick3DEffect::appendParameter, + &Quick3DEffect::parametersCount, + &Quick3DEffect::parameterAt, + &Quick3DEffect::clearParameterList); +} + +void Quick3DEffect::appendTechnique(QQmlListProperty<QTechnique> *list, QTechnique *bar) +{ + Quick3DEffect *eff = qobject_cast<Quick3DEffect*>(list->object); + if (eff) + eff->parentEffect()->addTechnique(bar); +} + +// TO DO : Return a QAbstractTechnique once properly defined +QTechnique *Quick3DEffect::techniqueAt(QQmlListProperty<QTechnique> *list, int index) +{ + Quick3DEffect *eff = qobject_cast<Quick3DEffect*>(list->object); + if (eff) + return qobject_cast<QTechnique*>(eff->parentEffect()->techniques().at(index)); + return Q_NULLPTR; +} + +int Quick3DEffect::techniqueCount(QQmlListProperty<QTechnique> *list) +{ + Quick3DEffect *eff = qobject_cast<Quick3DEffect*>(list->object); + if (eff) + return eff->parentEffect()->techniques().count(); + return 0; +} + +void Quick3DEffect::clearTechniqueList(QQmlListProperty<QTechnique> *list) +{ + Quick3DEffect *eff = qobject_cast<Quick3DEffect*>(list->object); + if (eff) { + // Ownership of techniques is handled by the QmlEngine so we shouldn't class clearTechniques + // which deletes techniques + Q_FOREACH (QTechnique *tech, eff->parentEffect()->techniques()) + eff->parentEffect()->removeTechnique(tech); + } +} + +void Quick3DEffect::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param) +{ + Quick3DEffect *effect = qobject_cast<Quick3DEffect *>(list->object); + qobject_cast<QEffect *>(effect->parentEffect())->addParameter(param); +} + +QParameter *Quick3DEffect::parameterAt(QQmlListProperty<QParameter> *list, int index) +{ + Quick3DEffect *effect = qobject_cast<Quick3DEffect *>(list->object); + return qobject_cast<QEffect *>(effect->parentEffect())->parameters().at(index); +} + +int Quick3DEffect::parametersCount(QQmlListProperty<QParameter> *list) +{ + Quick3DEffect *effect = qobject_cast<Quick3DEffect *>(list->object); + return qobject_cast<QEffect *>(effect->parentEffect())->parameters().count(); +} + +void Quick3DEffect::clearParameterList(QQmlListProperty<QParameter> *list) +{ + Quick3DEffect *effect = qobject_cast<Quick3DEffect *>(list->object); + Q_FOREACH (QParameter *p, qobject_cast<QEffect *>(effect->parentEffect())->parameters()) + qobject_cast<QEffect *>(effect->parentEffect())->removeParameter(p); +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3deffect.h b/src/quick3d/quick3drender/items/quick3deffect.h new file mode 100644 index 000000000..2d4b7a023 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3deffect.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DEFFECT_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DEFFECT_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <QQmlListProperty> +#include <Qt3DRender/qeffect.h> +#include <Qt3DRender/qtechnique.h> + + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DEffect : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QTechnique> techniques READ techniqueList) + Q_PROPERTY(QQmlListProperty<Qt3DRender::QParameter> parameters READ parameterList) + +public: + explicit Quick3DEffect(QObject *parent = 0); + + inline QEffect *parentEffect() const { return qobject_cast<QEffect*>(parent()); } + + QQmlListProperty<QTechnique> techniqueList(); + QQmlListProperty<QParameter> parameterList(); + +private: + static void appendTechnique(QQmlListProperty<QTechnique> *list, QTechnique *bar); + static QTechnique *techniqueAt(QQmlListProperty<QTechnique> *list, int index); + static int techniqueCount(QQmlListProperty<QTechnique> *list); + static void clearTechniqueList(QQmlListProperty<QTechnique> *list); + + static void appendParameter(QQmlListProperty<QParameter> *list, QParameter *param); + static QParameter *parameterAt(QQmlListProperty<QParameter> *list, int index); + static int parametersCount(QQmlListProperty<QParameter> *list); + static void clearParameterList(QQmlListProperty<QParameter> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DEFFECT_H diff --git a/src/quick3d/quick3drender/items/quick3dgeometry.cpp b/src/quick3d/quick3drender/items/quick3dgeometry.cpp new file mode 100644 index 000000000..b2af9763b --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dgeometry.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "quick3dgeometry.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DGeometry::Quick3DGeometry(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<Qt3DCore::QAbstractAttribute> Quick3DGeometry::attributeList() +{ + return QQmlListProperty<Qt3DCore::QAbstractAttribute>(this, 0, + &Quick3DGeometry::appendAttribute, + &Quick3DGeometry::attributesCount, + &Quick3DGeometry::attributeAt, + &Quick3DGeometry::clearAttributes); +} + +void Quick3DGeometry::appendAttribute(QQmlListProperty<Qt3DCore::QAbstractAttribute> *list, Qt3DCore::QAbstractAttribute *attribute) +{ + Quick3DGeometry *geometry = static_cast<Quick3DGeometry *>(list->object); + geometry->m_managedAttributes.append(attribute); + geometry->parentGeometry()->addAttribute(attribute); +} + +Qt3DCore::QAbstractAttribute *Quick3DGeometry::attributeAt(QQmlListProperty<Qt3DCore::QAbstractAttribute> *list, int index) +{ + Quick3DGeometry *geometry = static_cast<Quick3DGeometry *>(list->object); + return geometry->parentGeometry()->attributes().at(index); +} + +int Quick3DGeometry::attributesCount(QQmlListProperty<Qt3DCore::QAbstractAttribute> *list) +{ + Quick3DGeometry *geometry = static_cast<Quick3DGeometry *>(list->object); + return geometry->parentGeometry()->attributes().count(); +} + +void Quick3DGeometry::clearAttributes(QQmlListProperty<Qt3DCore::QAbstractAttribute> *list) +{ + Quick3DGeometry *geometry = static_cast<Quick3DGeometry *>(list->object); + QVector<Qt3DCore::QAbstractAttribute *> &managedAttributes = geometry->m_managedAttributes; + Q_FOREACH (Qt3DCore::QAbstractAttribute *attribute, managedAttributes) + geometry->parentGeometry()->removeAttribute(attribute); + managedAttributes.clear(); +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dgeometry.h b/src/quick3d/quick3drender/items/quick3dgeometry.h new file mode 100644 index 000000000..bb95be1d0 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dgeometry.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 QT3D_QUICK3DGEOMETRY_H +#define QT3D_QUICK3DGEOMETRY_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <QQmlListProperty> +#include <Qt3DRender/QGeometry> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DGeometry : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DCore::QAbstractAttribute> attributes READ attributeList) + Q_CLASSINFO("DefaultProperty", "attributes") + +public: + explicit Quick3DGeometry(QObject *parent = 0); + inline QGeometry *parentGeometry() const { return qobject_cast<QGeometry *>(parent()); } + + QQmlListProperty<Qt3DCore::QAbstractAttribute> attributeList(); + +private: + static void appendAttribute(QQmlListProperty<Qt3DCore::QAbstractAttribute> *list, Qt3DCore::QAbstractAttribute *provider); + static Qt3DCore::QAbstractAttribute *attributeAt(QQmlListProperty<Qt3DCore::QAbstractAttribute> *list, int index); + static int attributesCount(QQmlListProperty<Qt3DCore::QAbstractAttribute> *list); + static void clearAttributes(QQmlListProperty<Qt3DCore::QAbstractAttribute> *list); + + QVector<Qt3DCore::QAbstractAttribute *> m_managedAttributes; +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3D_QUICK3DGEOMETRY_H diff --git a/src/quick3d/quick3drender/items/quick3dmaterial.cpp b/src/quick3d/quick3drender/items/quick3dmaterial.cpp new file mode 100644 index 000000000..d66d1b21c --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dmaterial.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** 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 "quick3dmaterial.h" +#include <Qt3DRender/qtexture.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +namespace Quick { + +Quick3DMaterial::Quick3DMaterial(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QParameter> Quick3DMaterial::qmlParameters() +{ + return QQmlListProperty<QParameter>(this, 0, + &Quick3DMaterial::appendParameter, + &Quick3DMaterial::parameterCount, + &Quick3DMaterial::parameterAt, + &Quick3DMaterial::clearParameters); +} + +void Quick3DMaterial::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param) +{ + Quick3DMaterial *mat = qobject_cast<Quick3DMaterial *>(list->object); + if (mat) { + param->setParent(mat->parentMaterial()); + mat->parentMaterial()->addParameter(param); + } +} + +QParameter *Quick3DMaterial::parameterAt(QQmlListProperty<QParameter> *list, int index) +{ + Quick3DMaterial *mat = qobject_cast<Quick3DMaterial *>(list->object); + if (mat) + return mat->parentMaterial()->parameters().at(index); + return 0; +} + +int Quick3DMaterial::parameterCount(QQmlListProperty<QParameter> *list) +{ + Quick3DMaterial *mat = qobject_cast<Quick3DMaterial *>(list->object); + if (mat) + return mat->parentMaterial()->parameters().count(); + return 0; +} + +void Quick3DMaterial::clearParameters(QQmlListProperty<QParameter> *list) +{ + Quick3DMaterial *mat = qobject_cast<Quick3DMaterial *>(list->object); + if (mat) { + Q_FOREACH (QParameter *p, mat->parentMaterial()->parameters()) { + mat->parentMaterial()->removeParameter(p); + } + } +} + +} // Quick + +} // namespace Render + +} // Qt3D + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dmaterial.h b/src/quick3d/quick3drender/items/quick3dmaterial.h new file mode 100644 index 000000000..76838418b --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dmaterial.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DMATERIAL_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DMATERIAL_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qmaterial.h> +#include <Qt3DRender/qparameter.h> +#include <QQmlListProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +// FIXME - write a custom QML parser and stop mis-using Tag +// Tags could be replaced by Parameters directly + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DMaterial : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QParameter> parameters READ qmlParameters) + +public: + explicit Quick3DMaterial(QObject *parent = 0); + + // TO DO : replace by QAbstractMaterial later on + inline QMaterial *parentMaterial() const { return qobject_cast<QMaterial*>(parent()); } + + QQmlListProperty<QParameter> qmlParameters(); + + +private: + // FIXME - remove when we have a custom QML parser + static void appendParameter(QQmlListProperty<QParameter> *list, QParameter *bar); + static QParameter *parameterAt(QQmlListProperty<QParameter> *list, int index); + static int parameterCount(QQmlListProperty<QParameter> *list); + static void clearParameters(QQmlListProperty<QParameter> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DMATERIAL_H diff --git a/src/quick3d/quick3drender/items/quick3dparameter.cpp b/src/quick3d/quick3drender/items/quick3dparameter.cpp new file mode 100644 index 000000000..fe3e497a3 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dparameter.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 "quick3dparameter.h" +#include "quick3dparameter_p.h" + +#include <QJSValue> +#include <QJSValueIterator> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +namespace { +const int qjsValueTypeId = qMetaTypeId<QJSValue>(); +} + +Quick3DParameterPrivate::Quick3DParameterPrivate() + : QParameterPrivate() +{ +} + +void Quick3DParameterPrivate::setValue(const QVariant &value) +{ + if (value.userType() == qjsValueTypeId) { + QJSValue v = value.value<QJSValue>(); + if (v.isArray()) + QParameterPrivate::setValue(value.value<QVariantList>()); + } else { + QParameterPrivate::setValue(value); + } +} + +Quick3DParameter::Quick3DParameter(QNode *parent) + : QParameter(*new Quick3DParameterPrivate, parent) +{ +} + +/*! \internal */ +Quick3DParameter::Quick3DParameter(Quick3DParameterPrivate &dd, QNode *parent) + : QParameter(dd, parent) +{ +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + + diff --git a/src/quick3d/quick3drender/items/quick3dparameter.h b/src/quick3d/quick3drender/items/quick3dparameter.h new file mode 100644 index 000000000..cb1ccd057 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dparameter.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DPARAMETER_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DPARAMETER_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qparameter.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class Quick3DParameterPrivate; + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DParameter : public QParameter +{ + Q_OBJECT +public: + explicit Quick3DParameter(QNode *parent = 0); + +private: + Q_DECLARE_PRIVATE(Quick3DParameter) + +protected: + Quick3DParameter(Quick3DParameterPrivate &dd, QNode *parent = 0); + QT3D_CLONEABLE(Quick3DParameter) +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DPARAMETER_H diff --git a/src/quick3d/quick3drender/items/quick3dparameter_p.h b/src/quick3d/quick3drender/items/quick3dparameter_p.h new file mode 100644 index 000000000..56c1fa6a6 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dparameter_p.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DPARAMETER_P_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DPARAMETER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DRender/private/qparameter_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class Quick3DParameter; + +class Quick3DParameterPrivate : public QParameterPrivate +{ +public: + Quick3DParameterPrivate(); + + Q_DECLARE_PUBLIC(Quick3DParameter) + + void setValue(const QVariant &value) Q_DECL_OVERRIDE; +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DPARAMETER_P_H diff --git a/src/quick3d/quick3drender/items/quick3drenderpass.cpp b/src/quick3d/quick3drender/items/quick3drenderpass.cpp new file mode 100644 index 000000000..ff8089f4f --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3drenderpass.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies). +** 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 "quick3drenderpass.h" +#include <Qt3DRender/qparametermapping.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DRenderPass::Quick3DRenderPass(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QAnnotation> Quick3DRenderPass::annotationList() +{ + return QQmlListProperty<QAnnotation>(this, 0, + &Quick3DRenderPass::appendAnnotation, + &Quick3DRenderPass::annotationsCount, + &Quick3DRenderPass::annotationAt, + &Quick3DRenderPass::clearAnnotations); +} + +QQmlListProperty<QParameterMapping> Quick3DRenderPass::bindingList() +{ + return QQmlListProperty<QParameterMapping>(this, 0, + &Quick3DRenderPass::appendBinding, + &Quick3DRenderPass::bindingsCount, + &Quick3DRenderPass::bindingAt, + &Quick3DRenderPass::clearBindings); +} + +QQmlListProperty<QRenderState> Quick3DRenderPass::renderStateList() +{ + return QQmlListProperty<QRenderState>(this, 0, + &Quick3DRenderPass::appendRenderState, + &Quick3DRenderPass::renderStateCount, + &Quick3DRenderPass::renderStateAt, + &Quick3DRenderPass::clearRenderStates); +} + +QQmlListProperty<QParameter> Quick3DRenderPass::parameterList() +{ + return QQmlListProperty<QParameter>(this, 0, + &Quick3DRenderPass::appendParameter, + &Quick3DRenderPass::parametersCount, + &Quick3DRenderPass::parameterAt, + &Quick3DRenderPass::clearParameterList); +} + +void Quick3DRenderPass::appendAnnotation(QQmlListProperty<QAnnotation> *list, QAnnotation *annotation) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + rPass->parentRenderPass()->addAnnotation(annotation); +} + +QAnnotation *Quick3DRenderPass::annotationAt(QQmlListProperty<QAnnotation> *list, int index) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + return rPass->parentRenderPass()->annotations().at(index); +} + +int Quick3DRenderPass::annotationsCount(QQmlListProperty<QAnnotation> *list) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + return rPass->parentRenderPass()->annotations().count(); +} + +void Quick3DRenderPass::clearAnnotations(QQmlListProperty<QAnnotation> *list) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + Q_FOREACH (QAnnotation *c, rPass->parentRenderPass()->annotations()) + rPass->parentRenderPass()->removeAnnotation(c); +} + +void Quick3DRenderPass::appendBinding(QQmlListProperty<QParameterMapping> *list, QParameterMapping *binding) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + rPass->parentRenderPass()->addBinding(binding); +} + +QParameterMapping *Quick3DRenderPass::bindingAt(QQmlListProperty<QParameterMapping> *list, int index) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + return rPass->parentRenderPass()->bindings().at(index); +} + +int Quick3DRenderPass::bindingsCount(QQmlListProperty<QParameterMapping> *list) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + return rPass->parentRenderPass()->bindings().count(); +} + +void Quick3DRenderPass::clearBindings(QQmlListProperty<QParameterMapping> *list) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + Q_FOREACH (QParameterMapping *binding, rPass->parentRenderPass()->bindings()) + rPass->parentRenderPass()->removeBinding(binding); +} + +void Quick3DRenderPass::appendRenderState(QQmlListProperty<QRenderState> *list, QRenderState *state) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + rPass->parentRenderPass()->addRenderState(state); +} + +QRenderState *Quick3DRenderPass::renderStateAt(QQmlListProperty<QRenderState> *list, int index) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + return rPass->parentRenderPass()->renderStates().at(index); +} + +int Quick3DRenderPass::renderStateCount(QQmlListProperty<QRenderState> *list) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + return rPass->parentRenderPass()->renderStates().count(); +} + +void Quick3DRenderPass::clearRenderStates(QQmlListProperty<QRenderState> *list) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + Q_FOREACH (QRenderState *s, rPass->parentRenderPass()->renderStates()) + rPass->parentRenderPass()->removeRenderState(s); +} + +void Quick3DRenderPass::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + rPass->parentRenderPass()->addParameter(param); +} + +QParameter *Quick3DRenderPass::parameterAt(QQmlListProperty<QParameter> *list, int index) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + return rPass->parentRenderPass()->parameters().at(index); +} + +int Quick3DRenderPass::parametersCount(QQmlListProperty<QParameter> *list) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + return rPass->parentRenderPass()->parameters().count(); +} + +void Quick3DRenderPass::clearParameterList(QQmlListProperty<QParameter> *list) +{ + Quick3DRenderPass *rPass = qobject_cast<Quick3DRenderPass *>(list->object); + Q_FOREACH (QParameter *p, rPass->parentRenderPass()->parameters()) + rPass->parentRenderPass()->removeParameter(p); +} + + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3drenderpass.h b/src/quick3d/quick3drender/items/quick3drenderpass.h new file mode 100644 index 000000000..384d38486 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3drenderpass.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies). +** 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_RENDER_QUICK_QUICK3DRENDERPASS_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DRENDERPASS_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qrenderpass.h> +#include <QQmlListProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DRenderPass : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QAnnotation> annotations READ annotationList) + Q_PROPERTY(QQmlListProperty<Qt3DRender::QParameterMapping> bindings READ bindingList) + Q_PROPERTY(QQmlListProperty<Qt3DRender::QRenderState> renderStates READ renderStateList) + Q_PROPERTY(QQmlListProperty<Qt3DRender::QParameter> parameters READ parameterList) +public: + explicit Quick3DRenderPass(QObject *parent = 0); + + QQmlListProperty<QAnnotation> annotationList(); + QQmlListProperty<QParameterMapping> bindingList(); + QQmlListProperty<QRenderState> renderStateList(); + QQmlListProperty<QParameter> parameterList(); + + inline QRenderPass *parentRenderPass() const { return qobject_cast<QRenderPass *>(parent()); } + +private: + static void appendAnnotation(QQmlListProperty<QAnnotation> *list, QAnnotation *criterion); + static QAnnotation *annotationAt(QQmlListProperty<QAnnotation> *list, int index); + static int annotationsCount(QQmlListProperty<QAnnotation> *list); + static void clearAnnotations(QQmlListProperty<QAnnotation> *list); + + static void appendBinding(QQmlListProperty<QParameterMapping> *list, QParameterMapping *binding); + static QParameterMapping *bindingAt(QQmlListProperty<QParameterMapping> *list, int index); + static int bindingsCount(QQmlListProperty<QParameterMapping> *list); + static void clearBindings(QQmlListProperty<QParameterMapping> *list); + + static void appendRenderState(QQmlListProperty<QRenderState> *list, QRenderState *state); + static QRenderState *renderStateAt(QQmlListProperty<QRenderState> *list, int index); + static int renderStateCount(QQmlListProperty<QRenderState> *list); + static void clearRenderStates(QQmlListProperty<QRenderState> *list); + + static void appendParameter(QQmlListProperty<QParameter> *list, QParameter *param); + static QParameter *parameterAt(QQmlListProperty<QParameter> *list, int index); + static int parametersCount(QQmlListProperty<QParameter> *list); + static void clearParameterList(QQmlListProperty<QParameter> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DRENDERPASS_H diff --git a/src/quick3d/quick3drender/items/quick3drenderpassfilter.cpp b/src/quick3d/quick3drender/items/quick3drenderpassfilter.cpp new file mode 100644 index 000000000..d0dbf7dab --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3drenderpassfilter.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** 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 "quick3drenderpassfilter.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DRenderPassFilter::Quick3DRenderPassFilter(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QAnnotation> Quick3DRenderPassFilter::includeList() +{ + return QQmlListProperty<QAnnotation>(this, 0, + &Quick3DRenderPassFilter::appendInclude, + &Quick3DRenderPassFilter::includesCount, + &Quick3DRenderPassFilter::includeAt, + &Quick3DRenderPassFilter::clearIncludes); +} + +QQmlListProperty<QParameter> Quick3DRenderPassFilter::parameterList() +{ + return QQmlListProperty<QParameter>(this, 0, + &Quick3DRenderPassFilter::appendParameter, + &Quick3DRenderPassFilter::parametersCount, + &Quick3DRenderPassFilter::parameterAt, + &Quick3DRenderPassFilter::clearParameterList); + +} + +void Quick3DRenderPassFilter::appendInclude(QQmlListProperty<QAnnotation> *list, QAnnotation *annotation) +{ + Quick3DRenderPassFilter *filter = qobject_cast<Quick3DRenderPassFilter *>(list->object); + if (filter) { + annotation->setParent(filter->parentRenderPassFilter()); + filter->parentRenderPassFilter()->addInclude(annotation); + } +} + +QAnnotation *Quick3DRenderPassFilter::includeAt(QQmlListProperty<QAnnotation> *list, int index) +{ + Quick3DRenderPassFilter *filter = qobject_cast<Quick3DRenderPassFilter *>(list->object); + if (filter) + return filter->parentRenderPassFilter()->includes().at(index); + return 0; +} + +int Quick3DRenderPassFilter::includesCount(QQmlListProperty<QAnnotation> *list) +{ + Quick3DRenderPassFilter *filter = qobject_cast<Quick3DRenderPassFilter *>(list->object); + if (filter) + return filter->parentRenderPassFilter()->includes().count(); + return 0; +} + +void Quick3DRenderPassFilter::clearIncludes(QQmlListProperty<QAnnotation> *list) +{ + Quick3DRenderPassFilter *filter = qobject_cast<Quick3DRenderPassFilter *>(list->object); + if (filter) { + Q_FOREACH (QAnnotation *criterion, filter->parentRenderPassFilter()->includes()) + filter->parentRenderPassFilter()->removeInclude(criterion); + } +} + +void Quick3DRenderPassFilter::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param) +{ + Quick3DRenderPassFilter *rPassFilter = qobject_cast<Quick3DRenderPassFilter *>(list->object); + rPassFilter->parentRenderPassFilter()->addParameter(param); +} + +QParameter *Quick3DRenderPassFilter::parameterAt(QQmlListProperty<QParameter> *list, int index) +{ + Quick3DRenderPassFilter *rPassFilter = qobject_cast<Quick3DRenderPassFilter *>(list->object); + return rPassFilter->parentRenderPassFilter()->parameters().at(index); +} + +int Quick3DRenderPassFilter::parametersCount(QQmlListProperty<QParameter> *list) +{ + Quick3DRenderPassFilter *rPassFilter = qobject_cast<Quick3DRenderPassFilter *>(list->object); + return rPassFilter->parentRenderPassFilter()->parameters().count(); +} + +void Quick3DRenderPassFilter::clearParameterList(QQmlListProperty<QParameter> *list) +{ + Quick3DRenderPassFilter *rPassFilter = qobject_cast<Quick3DRenderPassFilter *>(list->object); + Q_FOREACH (QParameter *p, rPassFilter->parentRenderPassFilter()->parameters()) + rPassFilter->parentRenderPassFilter()->removeParameter(p); +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3drenderpassfilter.h b/src/quick3d/quick3drender/items/quick3drenderpassfilter.h new file mode 100644 index 000000000..bf98dbdd5 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3drenderpassfilter.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DRENDERPASSFILTER_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DRENDERPASSFILTER_H + +#include <Qt3DQuick/quick3dnode.h> +#include <Qt3DRender/qrenderpassfilter.h> +#include <Qt3DRender/qannotation.h> +#include <Qt3DQuickRender/qt3dquickrender_global.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DRenderPassFilter : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QAnnotation> includes READ includeList) + Q_PROPERTY(QQmlListProperty<Qt3DRender::QParameter> parameters READ parameterList) + +public: + explicit Quick3DRenderPassFilter(QObject *parent = 0); + + QQmlListProperty<QAnnotation> includeList(); + QQmlListProperty<QParameter> parameterList(); + + inline QRenderPassFilter *parentRenderPassFilter() const { return qobject_cast<Qt3DRender::QRenderPassFilter*>(parent()); } + +private: + static void appendInclude(QQmlListProperty<QAnnotation> *list, QAnnotation *criterion); + static QAnnotation *includeAt(QQmlListProperty<QAnnotation> *list, int index); + static int includesCount(QQmlListProperty<QAnnotation> *list); + static void clearIncludes(QQmlListProperty<QAnnotation> *list); + + static void appendParameter(QQmlListProperty<QParameter> *list, QParameter *param); + static QParameter *parameterAt(QQmlListProperty<QParameter> *list, int index); + static int parametersCount(QQmlListProperty<QParameter> *list); + static void clearParameterList(QQmlListProperty<QParameter> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DRENDERPASSFILTER_H diff --git a/src/quick3d/quick3drender/items/quick3drendertarget.cpp b/src/quick3d/quick3drender/items/quick3drendertarget.cpp new file mode 100644 index 000000000..2bd4cfe5b --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3drendertarget.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 "quick3drendertarget.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DRenderTarget::Quick3DRenderTarget(QObject * parent) + : QObject(parent) +{ +} + +QQmlListProperty<QRenderAttachment> Quick3DRenderTarget::qmlAttachments() +{ + return QQmlListProperty<QRenderAttachment>(this, 0, + &Quick3DRenderTarget::appendRenderAttachment, + &Quick3DRenderTarget::renderAttachmentCount, + &Quick3DRenderTarget::renderAttachmentAt, + &Quick3DRenderTarget::clearRenderAttachments); +} + +void Quick3DRenderTarget::appendRenderAttachment(QQmlListProperty<QRenderAttachment> *list, QRenderAttachment *attachment) +{ + Quick3DRenderTarget *rT = qobject_cast<Quick3DRenderTarget *>(list->object); + if (rT) + rT->parentRenderTarget()->addAttachment(attachment); +} + +QRenderAttachment *Quick3DRenderTarget::renderAttachmentAt(QQmlListProperty<QRenderAttachment> *list, int index) +{ + Quick3DRenderTarget *rT = qobject_cast<Quick3DRenderTarget *>(list->object); + if (rT) + return rT->parentRenderTarget()->attachments().at(index); + return Q_NULLPTR; +} + +int Quick3DRenderTarget::renderAttachmentCount(QQmlListProperty<QRenderAttachment> *list) +{ + Quick3DRenderTarget *rT = qobject_cast<Quick3DRenderTarget *>(list->object); + if (rT) + return rT->parentRenderTarget()->attachments().count(); + return -1; +} + +void Quick3DRenderTarget::clearRenderAttachments(QQmlListProperty<QRenderAttachment> *list) +{ + Quick3DRenderTarget *rT = qobject_cast<Quick3DRenderTarget *>(list->object); + if (rT) { + Q_FOREACH (QRenderAttachment *att, rT->parentRenderTarget()->attachments()) + rT->parentRenderTarget()->removeAttachment(att); + } +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3drendertarget.h b/src/quick3d/quick3drender/items/quick3drendertarget.h new file mode 100644 index 000000000..d61b0ef8b --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3drendertarget.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DRENDERTARGET_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DRENDERTARGET_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qrendertarget.h> +#include <Qt3DRender/qrenderattachment.h> +#include <QQmlListProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DRenderTarget : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QRenderAttachment> attachments READ qmlAttachments) +public: + explicit Quick3DRenderTarget(QObject *parent = 0); + + inline QRenderTarget *parentRenderTarget() const { return qobject_cast<QRenderTarget *>(parent()); } + QQmlListProperty<QRenderAttachment> qmlAttachments(); + +private: + static void appendRenderAttachment(QQmlListProperty<QRenderAttachment> *list, QRenderAttachment *attachment); + static QRenderAttachment *renderAttachmentAt(QQmlListProperty<QRenderAttachment> *list, int index); + static int renderAttachmentCount(QQmlListProperty<QRenderAttachment> *list); + static void clearRenderAttachments(QQmlListProperty<QRenderAttachment> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DRENDERTARGET_H diff --git a/src/quick3d/quick3drender/items/quick3drendertargetselector.cpp b/src/quick3d/quick3drender/items/quick3drendertargetselector.cpp new file mode 100644 index 000000000..e09bfd8f5 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3drendertargetselector.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "quick3drendertargetselector.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DRenderTargetSelector::Quick3DRenderTargetSelector(QObject *parent) + : QObject(parent) +{ +} + +Quick3DRenderTargetSelector::~Quick3DRenderTargetSelector() +{ +} + +QVariantList Quick3DRenderTargetSelector::drawBuffers() const +{ + // Converts RenderAttachmentType to int + QVariantList l; + Q_FOREACH (const QRenderAttachment::RenderAttachmentType &b, parentRenderTargetSelector()->drawBuffers()) + l.append(static_cast<int>(b)); + return l; +} + +void Quick3DRenderTargetSelector::setDrawBuffers(const QVariantList &buffers) +{ + if (buffers != drawBuffers()) { + + // Converts int to RenderAttachmentType + QList<QRenderAttachment::RenderAttachmentType> drawBuffersList; + Q_FOREACH (const QVariant &buf, buffers) + drawBuffersList.append(static_cast<QRenderAttachment::RenderAttachmentType>(buf.toInt())); + + parentRenderTargetSelector()->setDrawBuffers(drawBuffersList); + emit drawBuffersChanged(); + } +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3drendertargetselector.h b/src/quick3d/quick3drender/items/quick3drendertargetselector.h new file mode 100644 index 000000000..65bd93eb4 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3drendertargetselector.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DRENDERTARGETSELECTOR_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DRENDERTARGETSELECTOR_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qrenderattachment.h> +#include <Qt3DRender/qrendertargetselector.h> +#include <QQmlListProperty> +#include <QVariantList> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DRenderTargetSelector : public QObject +{ + Q_OBJECT + Q_PROPERTY(QVariantList drawBuffers READ drawBuffers WRITE setDrawBuffers NOTIFY drawBuffersChanged) +public: + explicit Quick3DRenderTargetSelector(QObject *parent = 0); + ~Quick3DRenderTargetSelector(); + + inline QRenderTargetSelector *parentRenderTargetSelector() const { return qobject_cast<QRenderTargetSelector *>(parent()); } + + QVariantList drawBuffers() const; + void setDrawBuffers(const QVariantList &drawBuffers); + +Q_SIGNALS: + void drawBuffersChanged(); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QUICK3DRENDERTARGETSELECTOR_H diff --git a/src/quick3d/quick3drender/items/quick3dscene.cpp b/src/quick3d/quick3drender/items/quick3dscene.cpp new file mode 100644 index 000000000..b28487829 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dscene.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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 "quick3dscene.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DScene::Quick3DScene(QObject *parent) + : QObject(parent) +{ +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dscene.h b/src/quick3d/quick3drender/items/quick3dscene.h new file mode 100644 index 000000000..4795de844 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dscene.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DSCENE_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DSCENE_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DQuick/quick3dentity.h> +#include <Qt3DRender/qabstractsceneloader.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DScene : public QObject +{ + Q_OBJECT +public: + explicit Quick3DScene(QObject *parent = 0); + + inline QAbstractSceneLoader *parentScene() const { return qobject_cast<QAbstractSceneLoader *>(parent()); } +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DSCENE_H diff --git a/src/quick3d/quick3drender/items/quick3dshaderdata.cpp b/src/quick3d/quick3drender/items/quick3dshaderdata.cpp new file mode 100644 index 000000000..714f0fed9 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dshaderdata.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** 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 "quick3dshaderdata.h" +#include <private/qshaderdata_p.h> + +#include <Qt3DQuickRender/quick3dshaderdataarray.h> +#include <QMetaProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +namespace { + +const int qjsValueTypeId = qMetaTypeId<QJSValue>(); +const int quick3DShaderDataArrayTypeId = qMetaTypeId<Quick3DShaderDataArray*>(); +const int quick3DShaderDataTypeId = qMetaTypeId<Quick3DShaderData*>(); + +} + +class Quick3DShaderDataPropertyReader : public PropertyReaderInterface +{ +public: + Quick3DShaderDataPropertyReader() + { + } + + QVariant readProperty(const QVariant &v) Q_DECL_OVERRIDE + { + // qjsValueTypeId are not compile time constant (no switch) + if (v.userType() == qjsValueTypeId) { + QJSValue jsValue = v.value<QJSValue>(); + if (jsValue.isArray()) + return v.value<QVariantList>(); + else if (jsValue.isVariant()) + return jsValue.toVariant(); + } else if (v.userType() == quick3DShaderDataArrayTypeId) { + Quick3DShaderDataArray *array = v.value<Quick3DShaderDataArray *>(); + QVariantList innerValues; + if (array) { + Q_FOREACH (QShaderData *d, array->values()) { + if (d) + innerValues.append(QVariant::fromValue(d->id())); + } + } + return innerValues; + } else if (v.userType() == quick3DShaderDataTypeId) { + Qt3DCore::QNodeId id; + QShaderData *shaderData = v.value<Quick3DShaderData *>(); + if (shaderData) + id = shaderData->id(); + return QVariant::fromValue(id); + } + return v; + } +}; + +Quick3DShaderData::Quick3DShaderData(QNode *parent) + : QShaderData(*new QShaderDataPrivate(PropertyReaderInterfacePtr(new Quick3DShaderDataPropertyReader())) + , parent) +{ +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dshaderdata.h b/src/quick3d/quick3drender/items/quick3dshaderdata.h new file mode 100644 index 000000000..fc8f5e18b --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dshaderdata.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DSHADERDATA_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DSHADERDATA_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qshaderdata.h> + +#include <QJSValue> +#include <QJSValueIterator> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DShaderData : public QShaderData +{ + Q_OBJECT +public: + explicit Quick3DShaderData(QNode *parent = 0); + +private: + QT3D_CLONEABLE(Quick3DShaderData) +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(Qt3DRender::Render::Quick::Quick3DShaderData*) + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DSHADERDATA_H diff --git a/src/quick3d/quick3drender/items/quick3dshaderdataarray.cpp b/src/quick3d/quick3drender/items/quick3dshaderdataarray.cpp new file mode 100644 index 000000000..3b863b35e --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dshaderdataarray.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** 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 "quick3dshaderdataarray.h" +#include <private/qshaderdata_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class Quick3DShaderDataArrayPrivate : public Qt3DCore::QNodePrivate +{ +public: + Quick3DShaderDataArrayPrivate() + : QNodePrivate() + {} + + QList<QShaderData *> m_values; +}; + +Quick3DShaderDataArray::Quick3DShaderDataArray(QNode *parent) + : QNode(*new Quick3DShaderDataArrayPrivate, parent) +{ +} + +Quick3DShaderDataArray::~Quick3DShaderDataArray() +{ + QNode::cleanup(); +} + +QQmlListProperty<QShaderData> Quick3DShaderDataArray::valuesList() +{ + return QQmlListProperty<QShaderData>(this, 0, + &Quick3DShaderDataArray::appendValue, + &Quick3DShaderDataArray::valueCount, + &Quick3DShaderDataArray::valueAt, + &Quick3DShaderDataArray::clearValues); +} + +QList<QShaderData *> Quick3DShaderDataArray::values() const +{ + Q_D(const Quick3DShaderDataArray); + return d->m_values; +} + +void Quick3DShaderDataArray::copy(const QNode *ref) +{ + QNode::copy(ref); + const Quick3DShaderDataArray *dataArray = static_cast<const Quick3DShaderDataArray *>(ref); + Q_FOREACH (QShaderData *v, dataArray->d_func()->m_values) + d_func()->m_values.append(static_cast<QShaderData *>(QNode::clone(v))); +} + +void Quick3DShaderDataArray::appendValue(QQmlListProperty<QShaderData> *list, QShaderData *bar) +{ + Quick3DShaderDataArray *self = static_cast<Quick3DShaderDataArray *>(list->object); + static_cast<Quick3DShaderDataArrayPrivate *>(Quick3DShaderDataArrayPrivate::get(self))->m_values.append(bar); +} + +QShaderData *Quick3DShaderDataArray::valueAt(QQmlListProperty<QShaderData> *list, int index) +{ + Quick3DShaderDataArray *self = static_cast<Quick3DShaderDataArray *>(list->object); + return static_cast<Quick3DShaderDataArrayPrivate *>(Quick3DShaderDataArrayPrivate::get(self))->m_values.at(index); +} + +int Quick3DShaderDataArray::valueCount(QQmlListProperty<QShaderData> *list) +{ + Quick3DShaderDataArray *self = static_cast<Quick3DShaderDataArray *>(list->object); + return static_cast<Quick3DShaderDataArrayPrivate *>(Quick3DShaderDataArrayPrivate::get(self))->m_values.count(); +} + +void Quick3DShaderDataArray::clearValues(QQmlListProperty<QShaderData> *list) +{ + Quick3DShaderDataArray *self = static_cast<Quick3DShaderDataArray *>(list->object); + static_cast<Quick3DShaderDataArrayPrivate *>(Quick3DShaderDataArrayPrivate::get(self))->m_values.clear(); +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dshaderdataarray.h b/src/quick3d/quick3drender/items/quick3dshaderdataarray.h new file mode 100644 index 000000000..82bdee7c2 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dshaderdataarray.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DSHADERDATAARRAY_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DSHADERDATAARRAY_H + +#include <Qt3DCore/qnode.h> +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DQuickRender/quick3dshaderdata.h> +#include <QQmlListProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +class QShaderData; + +namespace Render { +namespace Quick { + +class Quick3DShaderDataArrayPrivate; +class Quick3DShaderData; + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DShaderDataArray : public Qt3DCore::QNode +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QShaderData> values READ valuesList) + Q_CLASSINFO("DefaultProperty", "values") + +public: + explicit Quick3DShaderDataArray(Qt3DCore::QNode *parent = 0); + ~Quick3DShaderDataArray(); + QQmlListProperty<QShaderData> valuesList(); + QList<QShaderData *> values() const; + +protected: + void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE; + +private: + static void appendValue(QQmlListProperty<QShaderData> *list, QShaderData *bar); + static QShaderData *valueAt(QQmlListProperty<QShaderData> *list, int index); + static int valueCount(QQmlListProperty<QShaderData> *list); + static void clearValues(QQmlListProperty<QShaderData> *list); + Q_DECLARE_PRIVATE(Quick3DShaderDataArray) + QT3D_CLONEABLE(Quick3DShaderDataArray) +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(Qt3DRender::Render::Quick::Quick3DShaderDataArray*) + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DSHADERDATAARRAY_H diff --git a/src/quick3d/quick3drender/items/quick3dsortmethod.cpp b/src/quick3d/quick3drender/items/quick3dsortmethod.cpp new file mode 100644 index 000000000..2c04b054f --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dsortmethod.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 "quick3dsortmethod.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DSortMethod::Quick3DSortMethod(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QSortCriterion> Quick3DSortMethod::criteriaList() +{ + return QQmlListProperty<QSortCriterion>(this, 0, + &Quick3DSortMethod::appendCriterion, + &Quick3DSortMethod::criteriaCount, + &Quick3DSortMethod::criterionAt, + &Quick3DSortMethod::clearCriteria); +} + +void Quick3DSortMethod::appendCriterion(QQmlListProperty<QSortCriterion> *list, QSortCriterion *criterion) +{ + Quick3DSortMethod *sM = qobject_cast<Quick3DSortMethod *>(list->object); + if (sM != Q_NULLPTR) + sM->parentSortMethod()->addCriterion(criterion); +} + +QSortCriterion *Quick3DSortMethod::criterionAt(QQmlListProperty<QSortCriterion> *list, int index) +{ + Quick3DSortMethod *sM = qobject_cast<Quick3DSortMethod *>(list->object); + if (sM != Q_NULLPTR) + return sM->parentSortMethod()->criteria().at(index); + return Q_NULLPTR; +} + +int Quick3DSortMethod::criteriaCount(QQmlListProperty<QSortCriterion> *list) +{ + Quick3DSortMethod *sM = qobject_cast<Quick3DSortMethod *>(list->object); + if (sM != Q_NULLPTR) + return sM->parentSortMethod()->criteria().count(); + return -1; +} + +void Quick3DSortMethod::clearCriteria(QQmlListProperty<QSortCriterion> *list) +{ + Quick3DSortMethod *sM = qobject_cast<Quick3DSortMethod *>(list->object); + if (sM != Q_NULLPTR) { + Q_FOREACH (QSortCriterion *c, sM->parentSortMethod()->criteria()) + sM->parentSortMethod()->removeCriterion(c); + } +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dsortmethod.h b/src/quick3d/quick3drender/items/quick3dsortmethod.h new file mode 100644 index 000000000..672f13703 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dsortmethod.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DSORTMETHOD_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DSORTMETHOD_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qsortmethod.h> +#include <Qt3DRender/qsortcriterion.h> +#include <QQmlListProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DSortMethod : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QSortCriterion> criteria READ criteriaList) +public: + explicit Quick3DSortMethod(QObject *parent = 0); + + inline QSortMethod *parentSortMethod() const { return qobject_cast<QSortMethod *>(parent()); } + + QQmlListProperty<QSortCriterion> criteriaList(); + +private: + static void appendCriterion(QQmlListProperty<QSortCriterion> *list, QSortCriterion *criterion); + static QSortCriterion *criterionAt(QQmlListProperty<QSortCriterion> *list, int index); + static int criteriaCount(QQmlListProperty<QSortCriterion> *list); + static void clearCriteria(QQmlListProperty<QSortCriterion> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DSORTMETHOD_H diff --git a/src/quick3d/quick3drender/items/quick3dstateset.cpp b/src/quick3d/quick3drender/items/quick3dstateset.cpp new file mode 100644 index 000000000..c6acec6a7 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dstateset.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "quick3dstateset.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DStateSet::Quick3DStateSet(QObject *parent) + : QObject(parent) +{ +} + +Quick3DStateSet::~Quick3DStateSet() +{ +} + +QQmlListProperty<QRenderState> Quick3DStateSet::renderStateList() +{ + return QQmlListProperty<QRenderState>(this, 0, + &Quick3DStateSet::appendRenderState, + &Quick3DStateSet::renderStateCount, + &Quick3DStateSet::renderStateAt, + &Quick3DStateSet::clearRenderStates); + +} + +void Quick3DStateSet::appendRenderState(QQmlListProperty<QRenderState> *list, QRenderState *state) +{ + Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(list->object); + stateSet->parentStateSet()->addRenderState(state); +} + +QRenderState *Quick3DStateSet::renderStateAt(QQmlListProperty<QRenderState> *list, int index) +{ + Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(list->object); + return stateSet->parentStateSet()->renderStates().at(index); +} + +int Quick3DStateSet::renderStateCount(QQmlListProperty<QRenderState> *list) +{ + Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(list->object); + return stateSet->parentStateSet()->renderStates().count(); +} + +void Quick3DStateSet::clearRenderStates(QQmlListProperty<QRenderState> *list) +{ + Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(list->object); + Q_FOREACH (QRenderState *s, stateSet->parentStateSet()->renderStates()) + stateSet->parentStateSet()->removeRenderState(s); +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + diff --git a/src/quick3d/quick3drender/items/quick3dstateset.h b/src/quick3d/quick3drender/items/quick3dstateset.h new file mode 100644 index 000000000..bae3bb3d5 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dstateset.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DSTATESET_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DSTATESET_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qstateset.h> +#include <QQmlListProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DStateSet : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QRenderState> renderStates READ renderStateList CONSTANT) +public: + explicit Quick3DStateSet(QObject *parent = 0); + ~Quick3DStateSet(); + + QQmlListProperty<QRenderState> renderStateList(); + inline QStateSet *parentStateSet() const { return qobject_cast<QStateSet *>(parent()); } + +private: + static void appendRenderState(QQmlListProperty<QRenderState> *list, QRenderState *state); + static QRenderState *renderStateAt(QQmlListProperty<QRenderState> *list, int index); + static int renderStateCount(QQmlListProperty<QRenderState> *list); + static void clearRenderStates(QQmlListProperty<QRenderState> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DSTATESET_H diff --git a/src/quick3d/quick3drender/items/quick3dtechnique.cpp b/src/quick3d/quick3drender/items/quick3dtechnique.cpp new file mode 100644 index 000000000..21690e6fe --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dtechnique.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** 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 "quick3dtechnique.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DTechnique::Quick3DTechnique(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QRenderPass> Quick3DTechnique::renderPassList() +{ + return QQmlListProperty<QRenderPass>(this, 0, + &Quick3DTechnique::appendRenderPass, + &Quick3DTechnique::renderPassCount, + &Quick3DTechnique::renderPassAt, + &Quick3DTechnique::clearRenderPasses); +} + +QQmlListProperty<QParameter> Quick3DTechnique::parameterList() +{ + return QQmlListProperty<QParameter>(this, 0, + &Quick3DTechnique::appendParameter, + &Quick3DTechnique::parametersCount, + &Quick3DTechnique::parameterAt, + &Quick3DTechnique::clearParameterList); +} + +void Quick3DTechnique::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + technique->parentTechnique()->addParameter(param); +} + +QParameter *Quick3DTechnique::parameterAt(QQmlListProperty<QParameter> *list, int index) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + return technique->parentTechnique()->parameters().at(index); +} + +int Quick3DTechnique::parametersCount(QQmlListProperty<QParameter> *list) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + return technique->parentTechnique()->parameters().count(); +} + +void Quick3DTechnique::clearParameterList(QQmlListProperty<QParameter> *list) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + Q_FOREACH (QParameter *p, technique->parentTechnique()->parameters()) + technique->parentTechnique()->removeParameter(p); +} + +void Quick3DTechnique::appendRenderPass(QQmlListProperty<QRenderPass> *list, QRenderPass *renderPass) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + if (technique) { + technique->parentTechnique()->addPass(renderPass); + } +} + +QRenderPass *Quick3DTechnique::renderPassAt(QQmlListProperty<QRenderPass> *list, int index) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + if (technique) + return qobject_cast<QRenderPass *>(technique->parentTechnique()->renderPasses().at(index)); + return 0; +} + +int Quick3DTechnique::renderPassCount(QQmlListProperty<QRenderPass> *list) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + if (technique) + return technique->parentTechnique()->renderPasses().size(); + return 0; +} + +void Quick3DTechnique::clearRenderPasses(QQmlListProperty<QRenderPass> *list) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + if (technique) { + Q_FOREACH (QRenderPass *pass, technique->parentTechnique()->renderPasses()) + technique->parentTechnique()->removePass(pass); + } +} + +QQmlListProperty<QAnnotation> Quick3DTechnique::annotationList() +{ + return QQmlListProperty<QAnnotation>(this, 0, + &Quick3DTechnique::appendAnnotation, + &Quick3DTechnique::annotationCount, + &Quick3DTechnique::annotationAt, + &Quick3DTechnique::clearAnnotationList); +} + +void Quick3DTechnique::appendAnnotation(QQmlListProperty<QAnnotation> *list, QAnnotation *annotation) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + if (technique) { + if (!annotation->parent()) + annotation->setParent(technique->parentTechnique()); + technique->parentTechnique()->addAnnotation(annotation); + } +} + +QAnnotation *Quick3DTechnique::annotationAt(QQmlListProperty<QAnnotation> *list, int index) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + if (technique) + return technique->parentTechnique()->annotations().at(index); + return 0; +} + +int Quick3DTechnique::annotationCount(QQmlListProperty<QAnnotation> *list) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + if (technique) + return technique->parentTechnique()->annotations().size(); + return 0; +} + +void Quick3DTechnique::clearAnnotationList(QQmlListProperty<QAnnotation> *list) +{ + Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(list->object); + if (technique) { + Q_FOREACH (QAnnotation *a, technique->parentTechnique()->annotations()) + technique->parentTechnique()->removeAnnotation(a); + } +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dtechnique.h b/src/quick3d/quick3drender/items/quick3dtechnique.h new file mode 100644 index 000000000..75de6d530 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dtechnique.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DTECHNIQUE_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DTECHNIQUE_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qtechnique.h> +#include <QQmlListProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DTechnique : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QAnnotation> annotations READ annotationList) + Q_PROPERTY(QQmlListProperty<Qt3DRender::QRenderPass> renderPasses READ renderPassList) + Q_PROPERTY(QQmlListProperty<Qt3DRender::QParameter> parameters READ parameterList) +public: + explicit Quick3DTechnique(QObject *parent = 0); + + QQmlListProperty<QAnnotation> annotationList(); + QQmlListProperty<QRenderPass> renderPassList(); + QQmlListProperty<QParameter> parameterList(); + + // Use QAbstractTechnique when it has been properly defined + inline QTechnique *parentTechnique() const { return qobject_cast<QTechnique*>(parent()); } + +private: + + static void appendParameter(QQmlListProperty<QParameter> *list, QParameter *param); + static QParameter *parameterAt(QQmlListProperty<QParameter> *list, int index); + static int parametersCount(QQmlListProperty<QParameter> *list); + static void clearParameterList(QQmlListProperty<QParameter> *list); + + static void appendAnnotation(QQmlListProperty<QAnnotation> *list, QAnnotation *Annotation); + static QAnnotation *annotationAt(QQmlListProperty<QAnnotation> *list, int index); + static int annotationCount(QQmlListProperty<QAnnotation> *list); + static void clearAnnotationList(QQmlListProperty<QAnnotation> *list); + + static void appendRenderPass(QQmlListProperty<QRenderPass> *list, QRenderPass* renderPass); + static QRenderPass *renderPassAt(QQmlListProperty<QRenderPass> *list, int index); + static int renderPassCount(QQmlListProperty<QRenderPass> *list); + static void clearRenderPasses( QQmlListProperty<QRenderPass> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DTECHNIQUE_H diff --git a/src/quick3d/quick3drender/items/quick3dtechniquefilter.cpp b/src/quick3d/quick3drender/items/quick3dtechniquefilter.cpp new file mode 100644 index 000000000..936efc738 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dtechniquefilter.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** 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 "quick3dtechniquefilter.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DTechniqueFilter::Quick3DTechniqueFilter(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QAnnotation> Quick3DTechniqueFilter::requireList() +{ + return QQmlListProperty<QAnnotation>(this, 0, + &Quick3DTechniqueFilter::appendRequire, + &Quick3DTechniqueFilter::requiresCount, + &Quick3DTechniqueFilter::requireAt, + &Quick3DTechniqueFilter::clearRequires); +} + +QQmlListProperty<QParameter> Quick3DTechniqueFilter::parameterList() +{ + return QQmlListProperty<QParameter>(this, 0, + &Quick3DTechniqueFilter::appendParameter, + &Quick3DTechniqueFilter::parametersCount, + &Quick3DTechniqueFilter::parameterAt, + &Quick3DTechniqueFilter::clearParameterList); +} + +void Quick3DTechniqueFilter::appendRequire(QQmlListProperty<QAnnotation> *list, QAnnotation *criterion) +{ + Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(list->object); + if (filter) { + criterion->setParent(filter->parentTechniqueFilter()); + filter->parentTechniqueFilter()->addRequirement(criterion); + } +} + +QAnnotation *Quick3DTechniqueFilter::requireAt(QQmlListProperty<QAnnotation> *list, int index) +{ + Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(list->object); + if (filter) + return filter->parentTechniqueFilter()->criteria().at(index); + return 0; +} + +int Quick3DTechniqueFilter::requiresCount(QQmlListProperty<QAnnotation> *list) +{ + Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(list->object); + if (filter) + return filter->parentTechniqueFilter()->criteria().size(); + return 0; +} + +void Quick3DTechniqueFilter::clearRequires(QQmlListProperty<QAnnotation> *list) +{ + Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(list->object); + if (filter) { + Q_FOREACH (QAnnotation *criterion, filter->parentTechniqueFilter()->criteria()) + filter->parentTechniqueFilter()->removeRequirement(criterion); + } +} + +void Quick3DTechniqueFilter::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param) +{ + Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(list->object); + techniqueFilter->parentTechniqueFilter()->addParameter(param); +} + +QParameter *Quick3DTechniqueFilter::parameterAt(QQmlListProperty<QParameter> *list, int index) +{ + Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(list->object); + return techniqueFilter->parentTechniqueFilter()->parameters().at(index); +} + +int Quick3DTechniqueFilter::parametersCount(QQmlListProperty<QParameter> *list) +{ + Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(list->object); + return techniqueFilter->parentTechniqueFilter()->parameters().count(); +} + +void Quick3DTechniqueFilter::clearParameterList(QQmlListProperty<QParameter> *list) +{ + Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(list->object); + Q_FOREACH (QParameter *p, techniqueFilter->parentTechniqueFilter()->parameters()) + techniqueFilter->parentTechniqueFilter()->removeParameter(p); +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dtechniquefilter.h b/src/quick3d/quick3drender/items/quick3dtechniquefilter.h new file mode 100644 index 000000000..489a70c25 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dtechniquefilter.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DTECHNIQUEFILTER_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DTECHNIQUEFILTER_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DRender/qtechniquefilter.h> +#include <Qt3DRender/qannotation.h> +#include <Qt3DQuick/quick3dnode.h> +#include <QQmlListProperty> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DTechniqueFilter : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QAnnotation> requires READ requireList) + Q_PROPERTY(QQmlListProperty<Qt3DRender::QParameter> parameters READ parameterList) + +public: + explicit Quick3DTechniqueFilter(QObject *parent = 0); + + QQmlListProperty<QAnnotation> requireList(); + QQmlListProperty<QParameter> parameterList(); + + inline QTechniqueFilter *parentTechniqueFilter() const { return qobject_cast<QTechniqueFilter*>(parent()); } + +private: + static void appendRequire(QQmlListProperty<QAnnotation> *list, QAnnotation *criterion); + static QAnnotation *requireAt(QQmlListProperty<QAnnotation> *list, int index); + static int requiresCount(QQmlListProperty<QAnnotation> *list); + static void clearRequires(QQmlListProperty<QAnnotation> *list); + + static void appendParameter(QQmlListProperty<QParameter> *list, QParameter *param); + static QParameter *parameterAt(QQmlListProperty<QParameter> *list, int index); + static int parametersCount(QQmlListProperty<QParameter> *list); + static void clearParameterList(QQmlListProperty<QParameter> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DTECHNIQUEFILTER_H diff --git a/src/quick3d/quick3drender/items/quick3dtexture.cpp b/src/quick3d/quick3drender/items/quick3dtexture.cpp new file mode 100644 index 000000000..bfe899802 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dtexture.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 "quick3dtexture.h" +#include <QDebug> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DTextureExtension::Quick3DTextureExtension(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QAbstractTextureImage> Quick3DTextureExtension::textureImages() +{ + return QQmlListProperty<QAbstractTextureImage>(this, 0, + &Quick3DTextureExtension::appendTextureImage, + &Quick3DTextureExtension::textureImageCount, + &Quick3DTextureExtension::textureImageAt, + &Quick3DTextureExtension::clearTextureImageList); +} + +void Quick3DTextureExtension::appendTextureImage(QQmlListProperty<QAbstractTextureImage> *list, QAbstractTextureImage *textureImage) +{ + Quick3DTextureExtension *self = qobject_cast<Quick3DTextureExtension *>(list->object); + if (self) + self->parentTexture()->addTextureImage(textureImage); +} + +QAbstractTextureImage *Quick3DTextureExtension::textureImageAt(QQmlListProperty<QAbstractTextureImage> *list, int index) +{ + Quick3DTextureExtension *self = qobject_cast<Quick3DTextureExtension *>(list->object); + if (self) + return self->parentTexture()->textureImages().at(index); + return Q_NULLPTR; +} + +int Quick3DTextureExtension::textureImageCount(QQmlListProperty<QAbstractTextureImage> *list) +{ + Quick3DTextureExtension *self = qobject_cast<Quick3DTextureExtension *>(list->object); + if (self) + return self->parentTexture()->textureImages().count(); + return 0; +} + +void Quick3DTextureExtension::clearTextureImageList(QQmlListProperty<QAbstractTextureImage> *list) +{ + Quick3DTextureExtension *self = qobject_cast<Quick3DTextureExtension *>(list->object); + if (self) + Q_FOREACH (QAbstractTextureImage *img, self->parentTexture()->textureImages()) + self->parentTexture()->removeTextureImage(img); +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dtexture.h b/src/quick3d/quick3drender/items/quick3dtexture.h new file mode 100644 index 000000000..1369b1610 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dtexture.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DTEXTURE_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DTEXTURE_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DQuick/quick3dnode.h> +#include <Qt3DRender/qtexture.h> + +#include <QQmlListProperty> +#include <QUrl> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DTextureExtension : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QAbstractTextureImage> textureImages READ textureImages) + Q_CLASSINFO("DefaultProperty", "textureImages") + +public: + explicit Quick3DTextureExtension(QObject *parent = 0); + + QQmlListProperty<QAbstractTextureImage> textureImages(); + inline QAbstractTextureProvider *parentTexture() const { return qobject_cast<QAbstractTextureProvider *>(parent()); } + +private: + static void appendTextureImage(QQmlListProperty<QAbstractTextureImage> *list, QAbstractTextureImage *textureImage); + static QAbstractTextureImage *textureImageAt(QQmlListProperty<QAbstractTextureImage> *list, int index); + static int textureImageCount(QQmlListProperty<QAbstractTextureImage> *list); + static void clearTextureImageList(QQmlListProperty<QAbstractTextureImage> *list); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DTEXTURE_H diff --git a/src/quick3d/quick3drender/items/quick3dviewport.cpp b/src/quick3d/quick3drender/items/quick3dviewport.cpp new file mode 100644 index 000000000..0383c578b --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dviewport.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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 "quick3dviewport.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +Quick3DViewport::Quick3DViewport(QObject *parent) + : QObject(parent) +{ +} + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/quick3dviewport.h b/src/quick3d/quick3drender/items/quick3dviewport.h new file mode 100644 index 000000000..046c67223 --- /dev/null +++ b/src/quick3d/quick3drender/items/quick3dviewport.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_QUICK3DVIEWPORT_H +#define QT3DRENDER_RENDER_QUICK_QUICK3DVIEWPORT_H + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DQuick/quick3dnode.h> +#include <Qt3DRender/qviewport.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +// TO DO : Check if this is required or if this might as well be removed + +class QT3DQUICKRENDERSHARED_EXPORT Quick3DViewport : public QObject +{ + Q_OBJECT +public: + explicit Quick3DViewport(QObject *parent = 0); +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DVIEWPORT_H + diff --git a/src/quick3d/quick3drender/items/shaderpropertyparser.cpp b/src/quick3d/quick3drender/items/shaderpropertyparser.cpp new file mode 100644 index 000000000..a467cf678 --- /dev/null +++ b/src/quick3d/quick3drender/items/shaderpropertyparser.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 "shaderpropertyparser_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +namespace Quick { + +ShaderPropertyParser::ShaderPropertyParser() + : QQmlCustomParser(AcceptsAttachedProperties) +{ +} + +void ShaderPropertyParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, + const QList<const QV4::CompiledData::Binding *> &bindings) +{ + // TODO: Complete below when a proper Uniform API is defined + Q_FOREACH (const QV4::CompiledData::Binding *binding, bindings) { + QString propertyName = qmlUnit->stringAt(binding->propertyNameIndex); + qDebug() << Q_FUNC_INFO << "propertyName " << propertyName; + + if (binding->type == QV4::CompiledData::Binding::Type_Object) { + qDebug() << Q_FUNC_INFO << "Object property"; + } + else if (binding->type >= QV4::CompiledData::Binding::Type_AttachedProperty) { + qDebug() << Q_FUNC_INFO << "Attached property"; + } + else if (binding->type >= QV4::CompiledData::Binding::Type_GroupProperty) { + qDebug() << Q_FUNC_INFO << "Group property"; + } + else if (binding->type >= QV4::CompiledData::Binding::Type_String) { + qDebug() << Q_FUNC_INFO << "String property"; + } + else if (binding->type >= QV4::CompiledData::Binding::Type_Boolean) { + qDebug() << Q_FUNC_INFO << "Boolean property"; + } + else if (binding->type >= QV4::CompiledData::Binding::Type_Number) { + qDebug() << Q_FUNC_INFO << "Number property"; + } + else if (binding->type >= QV4::CompiledData::Binding::Type_Script) { + qDebug() << Q_FUNC_INFO << "Script property"; + } + } +} + +void ShaderPropertyParser::applyBindings(QObject *, QQmlCompiledData *, const QList<const QV4::CompiledData::Binding *> &) +{ + // TODO: Implement me +} + +} // Quick + +} // namespace Render + +} // Qt3D + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drender/items/shaderpropertyparser_p.h b/src/quick3d/quick3drender/items/shaderpropertyparser_p.h new file mode 100644 index 000000000..431c2e4b5 --- /dev/null +++ b/src/quick3d/quick3drender/items/shaderpropertyparser_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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_RENDER_QUICK_SHADERPROPERTYPARSER_H +#define QT3DRENDER_RENDER_QUICK_SHADERPROPERTYPARSER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <QtQml/private/qqmlcustomparser_p.h> +#include <QtQml/private/qv4compileddata_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { +namespace Quick { + +class QT3DQUICKRENDERSHARED_EXPORT ShaderPropertyParser : public QQmlCustomParser +{ +public: + ShaderPropertyParser(); + + QByteArray compile(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings); + void setCustomData(QObject *, const QByteArray &, QQmlCompiledData *); + + void verifyBindings(const QV4::CompiledData::Unit *, const QList<const QV4::CompiledData::Binding *> &) Q_DECL_OVERRIDE; + void applyBindings(QObject *, QQmlCompiledData *, const QList<const QV4::CompiledData::Binding *> &) Q_DECL_OVERRIDE; +}; + +} // namespace Quick +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_SHADERPROPERTYPARSER_H |