summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick3d/imports/render/qt3dquick3drenderplugin.cpp2
-rw-r--r--src/render/renderstates/qlinewidth.cpp109
-rw-r--r--src/render/renderstates/qlinewidth.h76
-rw-r--r--src/render/renderstates/qlinewidth_p.h69
-rw-r--r--src/render/renderstates/renderstates.cpp11
-rw-r--r--src/render/renderstates/renderstates.pri3
-rw-r--r--src/render/renderstates/renderstates_p.h7
-rw-r--r--src/render/renderstates/renderstateset.cpp11
-rw-r--r--src/render/renderstates/statemask_p.h1
-rw-r--r--src/render/renderstates/statevariant.cpp5
-rw-r--r--src/render/renderstates/statevariant_p.h1
11 files changed, 295 insertions, 0 deletions
diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
index f81b1fa53..1bdc7c4bb 100644
--- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
+++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
@@ -71,6 +71,7 @@
#include <Qt3DRender/qlevelofdetail.h>
#include <Qt3DRender/qlevelofdetailboundingsphere.h>
#include <Qt3DRender/qlevelofdetailswitch.h>
+#include <Qt3DRender/qlinewidth.h>
#include <Qt3DRender/qmemorybarrier.h>
#include <Qt3DRender/qmesh.h>
#include <Qt3DRender/qmultisampleantialiasing.h>
@@ -284,6 +285,7 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri)
qmlRegisterType<Qt3DRender::QSeamlessCubemap>(uri, 2, 0, "SeamlessCubemap");
qmlRegisterType<Qt3DRender::QStencilOperation>(uri, 2, 0, "StencilOperation");
qmlRegisterType<Qt3DRender::QStencilMask>(uri, 2, 0, "StencilMask");
+ qmlRegisterType<Qt3DRender::QLineWidth>(uri, 2, 10, "LineWidth");
}
QT_END_NAMESPACE
diff --git a/src/render/renderstates/qlinewidth.cpp b/src/render/renderstates/qlinewidth.cpp
new file mode 100644
index 000000000..5f85406a0
--- /dev/null
+++ b/src/render/renderstates/qlinewidth.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlinewidth.h"
+#include "qlinewidth_p.h"
+
+#include <Qt3DRender/private/qrenderstatecreatedchange_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+/*!
+ \class Qt3DRender::QLineWidth
+ \inmodule Qt3DRender
+ \since 5.10
+ \brief Specifies the width of rasterized lines.
+ */
+
+/*!
+ \qmltype LineWidth
+ \since 5.10
+ \inherits RenderState
+ \instantiates Qt3DRender::QLineWidth
+ \inqmlmodule Qt3D.Render
+
+ \brief Specifies the width of rasterized lines.
+ */
+
+/*!
+ \qmlproperty real LineWidth::value
+ Specifies the width value to be used.
+*/
+
+/*!
+ \property QLineWidth::value
+ Specifies the width value to be used.
+*/
+
+QLineWidth::QLineWidth(Qt3DCore::QNode *parent)
+ : QRenderState(*new QLineWidthPrivate(1.0f), parent)
+{
+}
+
+QLineWidth::~QLineWidth()
+{
+}
+
+float QLineWidth::value() const
+{
+ Q_D(const QLineWidth);
+ return d->m_value;
+}
+
+void QLineWidth::setValue(float width)
+{
+ Q_D(QLineWidth);
+ d->m_value = width;
+ emit valueChanged(width);
+}
+
+Qt3DCore::QNodeCreatedChangeBasePtr QLineWidth::createNodeCreationChange() const
+{
+ auto creationChange = QRenderStateCreatedChangePtr<QLineWidthData>::create(this);
+ auto &data = creationChange->data;
+ Q_D(const QLineWidth);
+ data.value = d->m_value;
+ return creationChange;
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/renderstates/qlinewidth.h b/src/render/renderstates/qlinewidth.h
new file mode 100644
index 000000000..c198981aa
--- /dev/null
+++ b/src/render/renderstates/qlinewidth.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QT3DRENDER_QLINEWIDTH_H
+#define QT3DRENDER_QLINEWIDTH_H
+
+#include <Qt3DRender/qrenderstate.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QLineWidthPrivate;
+
+class QT3DRENDERSHARED_EXPORT QLineWidth : public QRenderState
+{
+ Q_OBJECT
+ Q_PROPERTY(float value READ value WRITE setValue NOTIFY valueChanged)
+
+public:
+ explicit QLineWidth(Qt3DCore::QNode *parent = nullptr);
+ ~QLineWidth();
+
+ float value() const;
+
+public Q_SLOTS:
+ void setValue(float value);
+
+Q_SIGNALS:
+ void valueChanged(float value);
+
+private:
+ Q_DECLARE_PRIVATE(QLineWidth)
+ Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const Q_DECL_OVERRIDE;
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QTRENDER_QLINEWIDTH_H
diff --git a/src/render/renderstates/qlinewidth_p.h b/src/render/renderstates/qlinewidth_p.h
new file mode 100644
index 000000000..42f9a961f
--- /dev/null
+++ b/src/render/renderstates/qlinewidth_p.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 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_QLINEWIDTH_P_H
+#define QT3DRENDER_QLINEWIDTH_P_H
+
+#include <Qt3DRender/private/qrenderstate_p.h>
+#include <Qt3DRender/qlinewidth.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QLineWidthPrivate : public QRenderStatePrivate
+{
+public:
+ QLineWidthPrivate(float value)
+ : QRenderStatePrivate(Render::LineWidthMask)
+ , m_value(value)
+ {}
+
+ float m_value;
+
+ Q_DECLARE_PUBLIC(QLineWidth)
+};
+
+struct QLineWidthData
+{
+ float value;
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QLINEWIDTH_P_H
diff --git a/src/render/renderstates/renderstates.cpp b/src/render/renderstates/renderstates.cpp
index 9b99162d0..3f2573c8f 100644
--- a/src/render/renderstates/renderstates.cpp
+++ b/src/render/renderstates/renderstates.cpp
@@ -280,6 +280,17 @@ void StencilMask::updateProperty(const char *name, const QVariant &value)
else if (name == QByteArrayLiteral("backMask")) std::get<1>(m_values) = value.toInt();
}
+void LineWidth::apply(GraphicsContext *gc) const
+{
+ gc->openGLContext()->functions()->glLineWidth(std::get<0>(m_values));
+}
+
+void LineWidth::updateProperty(const char *name, const QVariant &value)
+{
+ if (name == QByteArrayLiteral("value"))
+ std::get<0>(m_values) = value.toFloat();
+}
+
} // namespace Render
} // namespace Qt3DRender
diff --git a/src/render/renderstates/renderstates.pri b/src/render/renderstates/renderstates.pri
index 76497d310..7418ce162 100644
--- a/src/render/renderstates/renderstates.pri
+++ b/src/render/renderstates/renderstates.pri
@@ -27,6 +27,7 @@ HEADERS += \
$$PWD/qseamlesscubemap.h \
$$PWD/qdepthtest.h \
$$PWD/qnodepthmask.h \
+ $$PWD/qlinewidth.h \
$$PWD/qalphatest_p.h \
$$PWD/qblendequation_p.h \
$$PWD/qblendequationarguments_p.h \
@@ -43,6 +44,7 @@ HEADERS += \
$$PWD/qstenciloperationarguments_p.h \
$$PWD/qstenciltest_p.h \
$$PWD/qstenciltestarguments_p.h \
+ $$PWD/qlinewidth_p.h \
$$PWD/renderstatenode_p.h \
$$PWD/qmultisampleantialiasing.h \
$$PWD/statemask_p.h \
@@ -73,6 +75,7 @@ SOURCES += \
$$PWD/qpointsize.cpp \
$$PWD/qseamlesscubemap.cpp \
$$PWD/qnodepthmask.cpp \
+ $$PWD/qlinewidth.cpp \
$$PWD/qrenderstatecreatedchange.cpp \
$$PWD/renderstatenode.cpp \
$$PWD/qmultisampleantialiasing.cpp \
diff --git a/src/render/renderstates/renderstates_p.h b/src/render/renderstates/renderstates_p.h
index c0062bb3d..cbd12a7b5 100644
--- a/src/render/renderstates/renderstates_p.h
+++ b/src/render/renderstates/renderstates_p.h
@@ -189,6 +189,13 @@ public:
void updateProperty(const char *name, const QVariant &value) Q_DECL_OVERRIDE;
};
+class Q_AUTOTEST_EXPORT LineWidth : public GenericState<LineWidth, LineWidthMask, GLfloat>
+{
+public:
+ void apply(GraphicsContext *gc) const Q_DECL_FINAL;
+ void updateProperty(const char *name, const QVariant &value) Q_DECL_OVERRIDE;
+};
+
} // namespace Render
} // namespace Qt3DRender
diff --git a/src/render/renderstates/renderstateset.cpp b/src/render/renderstates/renderstateset.cpp
index 992d649e8..c57a4fa0d 100644
--- a/src/render/renderstates/renderstateset.cpp
+++ b/src/render/renderstates/renderstateset.cpp
@@ -86,6 +86,8 @@
#include <Qt3DRender/private/qstenciloperationarguments_p.h>
#include <Qt3DRender/qstencilmask.h>
#include <Qt3DRender/private/qstencilmask_p.h>
+#include <Qt3DRender/qlinewidth.h>
+#include <Qt3DRender/private/qlinewidth_p.h>
QT_BEGIN_NAMESPACE
@@ -230,6 +232,9 @@ void RenderStateSet::resetMasked(StateMaskSet maskOfStatesToReset, GraphicsConte
if (maskOfStatesToReset & StencilOpMask)
funcs->glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+
+ if (maskOfStatesToReset & LineWidthMask)
+ funcs->glLineWidth(1.0f);
}
bool RenderStateSet::contains(const StateVariant &ds) const
@@ -368,6 +373,12 @@ StateVariant RenderStateSet::initializeStateFromPeer(const Qt3DRender::QRenderSt
data.backOutputMask);
}
+ case LineWidthMask: {
+ const auto typedChange = qSharedPointerCast<Qt3DRender::QRenderStateCreatedChange<QLineWidthData>>(change);
+ const auto &data = typedChange->data;
+ return RenderStateSet::createState<LineWidth>(data.value);
+ }
+
// TODO: Fix Dithering state
case DitheringStateMask:
default:
diff --git a/src/render/renderstates/statemask_p.h b/src/render/renderstates/statemask_p.h
index 16d229f8d..1f3305747 100644
--- a/src/render/renderstates/statemask_p.h
+++ b/src/render/renderstates/statemask_p.h
@@ -80,6 +80,7 @@ enum StateMask
SeamlessCubemapMask = 1 << 16,
MSAAEnabledStateMask = 1 << 17,
BlendEquationArgumentsMask = 1 << 18,
+ LineWidthMask = 1 << 19,
};
} // namespace Render
diff --git a/src/render/renderstates/statevariant.cpp b/src/render/renderstates/statevariant.cpp
index f472d9920..0db9b5a3c 100644
--- a/src/render/renderstates/statevariant.cpp
+++ b/src/render/renderstates/statevariant.cpp
@@ -105,6 +105,9 @@ void StateVariant::apply(GraphicsContext *gc) const
case StencilWriteStateMask:
data.stencilMask.apply(gc);
return;
+ case LineWidthMask:
+ data.lineWidth.apply(gc);
+ return;
default:
Q_UNREACHABLE();
}
@@ -136,6 +139,7 @@ RenderStateImpl *StateVariant::state()
case SeamlessCubemapMask:
case StencilOpMask:
case StencilWriteStateMask:
+ case LineWidthMask:
return &data.blendEquationArguments;
default:
Q_UNREACHABLE();
@@ -168,6 +172,7 @@ const RenderStateImpl *StateVariant::constState() const
case SeamlessCubemapMask:
case StencilOpMask:
case StencilWriteStateMask:
+ case LineWidthMask:
return &data.blendEquationArguments;
default:
Q_UNREACHABLE();
diff --git a/src/render/renderstates/statevariant_p.h b/src/render/renderstates/statevariant_p.h
index e13599e75..55ec23899 100644
--- a/src/render/renderstates/statevariant_p.h
+++ b/src/render/renderstates/statevariant_p.h
@@ -83,6 +83,7 @@ struct StateVariant
SeamlessCubemap seamlessCubemap;
StencilOp stencilOp;
StencilMask stencilMask;
+ LineWidth lineWidth;
u_Data()
{