summaryrefslogtreecommitdiffstats
path: root/src/render/frontend/qparameter.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-07-08 10:10:43 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-07-09 12:43:20 +0200
commit7977ff592528fc8fe2e3af5dc0285becd2455314 (patch)
treef9098ea957ea9d9d3d48a14aecc4e4c530c5801d /src/render/frontend/qparameter.cpp
parent64fc67331c933461beb68368147d3832d9e39655 (diff)
Renamed Parameter to QParameter
Change-Id: I1377b93ca06a838a625d38db8b77ebcee438b203 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/frontend/qparameter.cpp')
-rw-r--r--src/render/frontend/qparameter.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/src/render/frontend/qparameter.cpp b/src/render/frontend/qparameter.cpp
new file mode 100644
index 000000000..855e76772
--- /dev/null
+++ b/src/render/frontend/qparameter.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** 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 "qparameter.h"
+#include "renderlogging.h"
+#include <Qt3DCore/qscenepropertychange.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QParameter::QParameter(QNode *parent, const QString &name, const QVariant &value)
+ : QNode(parent)
+ , m_name(name)
+ , m_value(value)
+{
+}
+
+QParameter::QParameter(QNode *parent)
+ : QNode(parent)
+ , m_type(Undefined)
+{
+}
+
+QParameter::QParameter(QNode *parent, const QString &name, const QVariant &value, QParameter::OpenGLTypes ty)
+ : QNode(parent)
+ , m_name(name)
+ , m_type(ty)
+ , m_value(value)
+{
+
+}
+
+void QParameter::setName(const QString &name)
+{
+ if (m_name != name) {
+ m_name = name;
+ emit nameChanged();
+ }
+}
+
+void QParameter::setValue(const QVariant &dv)
+{
+ if (m_value != dv) {
+ m_value = dv;
+ emit valueChanged();
+ QScenePropertyChangePtr change(new QScenePropertyChange(ComponentUpdated, this));
+ change->m_propertyName = m_name.toUtf8();
+ change->m_value = m_value;
+ notifyObservers(change);
+ }
+}
+
+QVariant QParameter::value() const
+{
+ return m_value;
+}
+
+void QParameter::setDatatype(OpenGLTypes type)
+{
+ if (m_type != type) {
+ m_type = type;
+ emit datatypeChanged();
+ }
+}
+
+bool QParameter::isTextureType() const
+{
+ switch (m_type) {
+ case Sampler1D:
+ case Sampler2D:
+ case Sampler3D:
+ case SamplerCube:
+ return true;
+ default:
+ return false;
+ }
+}
+
+Render::QUniformValue::Type QParameter::uniformType() const
+{
+ switch (m_type) {
+ case Bool:
+ case BoolVec2:
+ case BoolVec3:
+ case BoolVec4:
+ return Render::QUniformValue::Bool;
+
+ // integers!
+
+ case Float:
+ case FloatVec2:
+ case FloatVec3:
+ case FloatVec4:
+ case FloatMat3:
+ case FloatMat4:
+ return Render::QUniformValue::Float;
+
+ case Double:
+ case DoubleVec2:
+ case DoubleVec3:
+ case DoubleVec4:
+ return Render::QUniformValue::Double;
+
+ default:
+ qCWarning(Render::Backend) << Q_FUNC_INFO << "couldn't map datatype:" << QString::number(m_type, 16);
+ return Render::QUniformValue::Invalid;
+ }
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE