summaryrefslogtreecommitdiffstats
path: root/src/render/backend/rendershaderdata.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire.ecortex@kdab.com>2014-11-17 08:00:40 +0100
committerSean Harmer <sean.harmer@kdab.com>2014-12-10 17:16:10 +0100
commit5d6d3117f2289e6eb68ca7c436073c7f5aab2ba8 (patch)
tree7d37b36b06764e436e57f28b5e592058c709bb59 /src/render/backend/rendershaderdata.cpp
parent24dd390e0208caeca20f96903049e26c723b12bd (diff)
RenderShaderData backend class for QShaderData
Change-Id: I2f303485d66446fc46a000ae6ebe564493d181e8 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/backend/rendershaderdata.cpp')
-rw-r--r--src/render/backend/rendershaderdata.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/render/backend/rendershaderdata.cpp b/src/render/backend/rendershaderdata.cpp
new file mode 100644
index 000000000..cf771d2ce
--- /dev/null
+++ b/src/render/backend/rendershaderdata.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:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "rendershaderdata_p.h"
+#include "qshaderdata.h"
+#include <QMetaProperty>
+#include <QMetaObject>
+#include <Qt3DCore/qscenepropertychange.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+namespace Render {
+
+RenderShaderData::RenderShaderData()
+ : QBackendNode()
+{
+}
+
+void RenderShaderData::updateFromPeer(QNode *peer)
+{
+ m_properties.clear();
+ const QShaderData *shaderData = static_cast<const QShaderData *>(peer);
+ const QMetaObject *metaObject = shaderData->metaObject();
+ const int propertyOffset = metaObject->propertyOffset();
+ const int propertyCount = metaObject->propertyCount();
+
+ for (int i = propertyOffset; i < propertyCount; ++i) {
+ const QMetaProperty property = metaObject->property(i);
+ m_properties.insert(property.name(), shaderData->property(property.name()));
+ }
+}
+
+void RenderShaderData::sceneChangeEvent(const QSceneChangePtr &e)
+{
+ if (e->type() == NodeUpdated) {
+ QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
+ if (m_properties.contains(propertyChange->propertyName()))
+ m_properties.insert(propertyChange->propertyName(), propertyChange->value());
+ }
+}
+
+} // Render
+
+} // Qt3D
+
+QT_END_NAMESPACE