summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2016-02-29 16:43:37 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-03-05 16:03:37 +0000
commitc00cadf3853942721cf8eb79b43cba78ceea658b (patch)
treeb0f30a5cc99dee18b4c6c8cbf830f16296c4d077 /src
parent6c0eecafa10ea3d8ff288d262bd0368bdf19a9c8 (diff)
QBlendState cleanup
* renamed to QBlendEquationArguments * property names expanded Change-Id: Id25f0181415b4f093f2054238dbf3be26e36ff32 Task-number: QTBUG-51509 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/sceneparsers/gltf/gltfparser.cpp8
-rw-r--r--src/quick3d/imports/render/defaults/qml/PhongAlphaMaterial.qml18
-rw-r--r--src/quick3d/imports/render/qt3dquick3drenderplugin.cpp4
-rw-r--r--src/render/defaults/qphongalphamaterial.cpp9
-rw-r--r--src/render/defaults/qphongalphamaterial_p.h4
-rw-r--r--src/render/renderstates/qblendequationarguments.cpp312
-rw-r--r--src/render/renderstates/qblendequationarguments.h (renamed from src/render/renderstates/qblendstate.h)82
-rw-r--r--src/render/renderstates/qblendstate.cpp324
-rw-r--r--src/render/renderstates/qrenderstate.h2
-rw-r--r--src/render/renderstates/renderstates.cpp16
-rw-r--r--src/render/renderstates/renderstates.pri8
-rw-r--r--src/render/renderstates/renderstates_p.h2
-rw-r--r--src/render/renderstates/renderstateset.cpp16
13 files changed, 396 insertions, 409 deletions
diff --git a/src/plugins/sceneparsers/gltf/gltfparser.cpp b/src/plugins/sceneparsers/gltf/gltfparser.cpp
index 7df17473f..3deafa796 100644
--- a/src/plugins/sceneparsers/gltf/gltfparser.cpp
+++ b/src/plugins/sceneparsers/gltf/gltfparser.cpp
@@ -1481,10 +1481,10 @@ QRenderState* GLTFParser::buildState(const QString& functionName, const QJsonVal
if (functionName == QStringLiteral("blendFuncSeparate")) {
type = GL_BLEND;
QBlendStateSeparate *blendState = new QBlendStateSeparate;
- blendState->setSrcRGB((QBlendState::Blending)values.at(0).toInt(GL_ONE));
- blendState->setSrcAlpha((QBlendState::Blending)values.at(1).toInt(GL_ONE));
- blendState->setDstRGB((QBlendState::Blending)values.at(2).toInt(GL_ZERO));
- blendState->setDstAlpha((QBlendState::Blending)values.at(3).toInt(GL_ZERO));
+ blendState->setSourceRgb((QBlendEquationArguments::Blending)values.at(0).toInt(GL_ONE));
+ blendState->setSourceAlpha((QBlendEquationArguments::Blending)values.at(1).toInt(GL_ONE));
+ blendState->setDestinationRgb((QBlendEquationArguments::Blending)values.at(2).toInt(GL_ZERO));
+ blendState->setDestinationAlpha((QBlendEquationArguments::Blending)values.at(3).toInt(GL_ZERO));
return blendState;
}
diff --git a/src/quick3d/imports/render/defaults/qml/PhongAlphaMaterial.qml b/src/quick3d/imports/render/defaults/qml/PhongAlphaMaterial.qml
index 383d708c8..750570727 100644
--- a/src/quick3d/imports/render/defaults/qml/PhongAlphaMaterial.qml
+++ b/src/quick3d/imports/render/defaults/qml/PhongAlphaMaterial.qml
@@ -91,9 +91,9 @@ Material {
shaderProgram: gl3PhongAlphaShader
renderStates: [
DepthMask { mask: false },
- BlendState {
- srcRGB: BlendState.SrcAlpha
- dstRGB: BlendState.OneMinusSrcAlpha
+ BlendEquationArguments {
+ sourceRgb: BlendEquationArguments.SourceAlpha
+ destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
},
BlendEquation {blendFunction: BlendEquation.Add}
]
@@ -113,9 +113,9 @@ Material {
shaderProgram: gl2es2PhongAlphaShader
renderStates: [
DepthMask { mask: false },
- BlendState {
- srcRGB: BlendState.SrcAlpha
- dstRGB: BlendState.OneMinusSrcAlpha
+ BlendEquationArguments {
+ sourceRgb: BlendEquationArguments.SourceAlpha
+ destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
},
BlendEquation {blendFunction: BlendEquation.Add}
]
@@ -135,9 +135,9 @@ Material {
shaderProgram: gl2es2PhongAlphaShader
renderStates: [
DepthMask { mask: false },
- BlendState {
- srcRGB: BlendState.SrcAlpha
- dstRGB: BlendState.OneMinusSrcAlpha
+ BlendEquationArguments {
+ sourceRgb: BlendEquationArguments.SourceAlpha
+ destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
},
BlendEquation {blendFunction: BlendEquation.Add}
]
diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
index 2944d6359..895a5df5d 100644
--- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
+++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
@@ -70,7 +70,7 @@
#include <Qt3DRender/qpointlight.h>
#include <Qt3DRender/qgraphicsapifilter.h>
#include <Qt3DRender/qrenderstate.h>
-#include <Qt3DRender/qblendstate.h>
+#include <Qt3DRender/qblendequationarguments.h>
#include <Qt3DRender/qblendequation.h>
#include <Qt3DRender/qalphatest.h>
#include <Qt3DRender/qdepthtest.h>
@@ -291,7 +291,7 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri)
// RenderStates
qmlRegisterUncreatableType<Qt3DRender::QRenderState>(uri, 2, 0, "RenderState", QStringLiteral("QRenderState is a base class"));
- qmlRegisterType<Qt3DRender::QBlendState>(uri, 2, 0, "BlendState");
+ qmlRegisterType<Qt3DRender::QBlendEquationArguments>(uri, 2, 0, "BlendEquationArguments");
qmlRegisterType<Qt3DRender::QBlendStateSeparate>(uri, 2, 0, "BlendStateSeparate");
qmlRegisterType<Qt3DRender::QBlendEquation>(uri, 2, 0, "BlendEquation");
qmlRegisterType<Qt3DRender::QAlphaTest>(uri, 2, 0, "AlphaTest");
diff --git a/src/render/defaults/qphongalphamaterial.cpp b/src/render/defaults/qphongalphamaterial.cpp
index 08c0fbe6d..2853333cb 100644
--- a/src/render/defaults/qphongalphamaterial.cpp
+++ b/src/render/defaults/qphongalphamaterial.cpp
@@ -48,7 +48,7 @@
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
#include <Qt3DRender/qblendequation.h>
-#include <Qt3DRender/qblendstate.h>
+#include <Qt3DRender/qblendequationarguments.h>
#include <Qt3DRender/qdepthmask.h>
#include <QUrl>
#include <QVector3D>
@@ -75,7 +75,7 @@ QPhongAlphaMaterialPrivate::QPhongAlphaMaterialPrivate()
, m_phongAlphaGL3Shader(new QShaderProgram())
, m_phongAlphaGL2ES2Shader(new QShaderProgram())
, m_depthMask(new QDepthMask())
- , m_blendState(new QBlendState())
+ , m_blendState(new QBlendEquationArguments())
, m_blendEquation(new QBlendEquation())
, m_annotation(new QAnnotation)
{
@@ -125,8 +125,9 @@ void QPhongAlphaMaterialPrivate::init()
m_phongAlphaES2Technique->addAnnotation(m_annotation);
m_depthMask->setMask(false);
- m_blendState->setSrcRGB(QBlendState::SrcAlpha);
- m_blendState->setDstRGB(QBlendState::OneMinusSrcAlpha);
+
+ m_blendState->setSourceRgb(QBlendEquationArguments::SourceAlpha);
+ m_blendState->setDestinationRgb(QBlendEquationArguments::OneMinusSourceAlpha);
m_blendEquation->setBlendFunction(QBlendEquation::Add);
m_phongAlphaGL3RenderPass->setShaderProgram(m_phongAlphaGL3Shader);
diff --git a/src/render/defaults/qphongalphamaterial_p.h b/src/render/defaults/qphongalphamaterial_p.h
index 67d4ac5d8..bf4eaadee 100644
--- a/src/render/defaults/qphongalphamaterial_p.h
+++ b/src/render/defaults/qphongalphamaterial_p.h
@@ -65,7 +65,7 @@ class QShaderProgram;
class QRenderPass;
class QParameterMapping;
class QDepthMask;
-class QBlendState;
+class QBlendEquationArguments;
class QBlendEquation;
class QPhongAlphaMaterial;
@@ -98,7 +98,7 @@ public:
QShaderProgram *m_phongAlphaGL3Shader;
QShaderProgram *m_phongAlphaGL2ES2Shader;
QDepthMask *m_depthMask;
- QBlendState *m_blendState;
+ QBlendEquationArguments *m_blendState;
QBlendEquation *m_blendEquation;
QAnnotation *m_annotation;
diff --git a/src/render/renderstates/qblendequationarguments.cpp b/src/render/renderstates/qblendequationarguments.cpp
new file mode 100644
index 000000000..c9e057732
--- /dev/null
+++ b/src/render/renderstates/qblendequationarguments.cpp
@@ -0,0 +1,312 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
+** 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 "qblendequationarguments.h"
+#include "qrenderstate_p.h"
+#include <Qt3DCore/qscenepropertychange.h>
+#include <private/qnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QBlendEquationArgumentsPrivate : public QRenderStatePrivate
+{
+public:
+ QBlendEquationArgumentsPrivate(QRenderState::Type type = QRenderState::BlendEquationArguments)
+ : QRenderStatePrivate(type)
+ , m_sourceRgb(QBlendEquationArguments::Zero)
+ , m_sourceAlpha(QBlendEquationArguments::Zero)
+ , m_destinationRgb(QBlendEquationArguments::Zero)
+ , m_destinationAlpha(QBlendEquationArguments::Zero)
+ , m_bufferIndex(-1)
+ {
+ }
+
+ Q_DECLARE_PUBLIC(QBlendEquationArguments)
+
+ QBlendEquationArguments::Blending m_sourceRgb;
+ QBlendEquationArguments::Blending m_sourceAlpha;
+ QBlendEquationArguments::Blending m_destinationRgb;
+ QBlendEquationArguments::Blending m_destinationAlpha;
+ int m_bufferIndex;
+};
+
+/*!
+ \class Qt3DRender::QBlendEquationArguments
+ \inmodule Qt3DRender
+ \since 5.5
+ \brief Encapsulates blending information.
+
+ OpenGL pre-3.0: Set the same blend state for all draw buffers
+ (one QBlendEquationArguments)
+ OpenGL 3.0-pre4.0: Set the same blend state for all draw buffers,
+ but can disable blending for particular buffers
+ (one QBlendEquationArguments for setting glBlendFunc, n QBlendEquationArgumentss
+ for enabling/disabling Draw Buffers)
+ OpenGL 4.0+: Can set blend state individually for each draw buffer.
+ */
+
+/*!
+ \qmltype BlendEquationArguments
+ \instantiates Qt3DRender::QBlendEquationArguments
+ \inherits RenderState
+ \inqmlmodule Qt3D.Render
+ \since 5.5
+ \brief Encapsulates blending information.
+
+ OpenGL pre-3.0: Set the same blend state for all draw buffers
+ OpenGL 3.0-pre4.0: Set the same blend state for all draw buffers,
+ but can disable blending for particular buffers
+ OpenGL 4.0+: Can set blend state individually for each draw buffer.
+*/
+
+/*!
+ The constructor creates a new blend state object with the specified \a parent.
+ */
+QBlendEquationArguments::QBlendEquationArguments(QNode *parent)
+ : QRenderState(*new QBlendEquationArgumentsPrivate, parent)
+{
+}
+
+QBlendEquationArguments::~QBlendEquationArguments()
+{
+ QNode::cleanup();
+}
+
+/*! \fn void QBlendEquationArguments::copy(const Qt3DCore::QNode *ref)
+ \internal
+ Copies \a ref into this object.
+ */
+void QBlendEquationArguments::copy(const QNode *ref)
+{
+ QRenderState::copy(ref);
+ const QBlendEquationArguments *refState = static_cast<const QBlendEquationArguments*>(ref);
+ d_func()->m_sourceRgb = refState->d_func()->m_sourceRgb;
+ d_func()->m_sourceAlpha = refState->d_func()->m_sourceAlpha;
+ d_func()->m_destinationAlpha = refState->d_func()->m_destinationAlpha;
+ d_func()->m_destinationRgb = refState->d_func()->m_destinationRgb;
+ d_func()->m_bufferIndex = refState->d_func()->m_bufferIndex;
+}
+
+/*!
+ \internal
+*/
+QBlendEquationArguments::QBlendEquationArguments(QRenderState::Type type, QNode *parent)
+ : QRenderState(*new QBlendEquationArgumentsPrivate(type), parent)
+{
+}
+
+/*!
+ \enum Qt3DRender::QBlendEquationArguments::Blending
+
+ \value Zero 0
+ \value One 1
+ \value SrcColor 0x0300
+ \value SourceAlpha 0x0302
+ \value Src1Alpha
+ \value Src1Color
+ \value DstColor 0x0306
+ \value destinationAlpha 0x0304
+ \value SourceAlphaSaturate 0x0308
+ \value ConstantColor 0x8001
+ \value ConstantAlpha 0x8003
+ \value OneMinusSrcColor 0x0301
+ \value OneMinusSourceAlpha 0x0303
+ \value OneMinusdestinationAlpha 0x0305
+ \value OneMinusDstColor 0x0307
+ \value OneMinusConstantColor 0x8002
+ \value OneMinusConstantAlpha 0x8004
+ \value OneMinusSrc1Alpha
+ \value OneMinusSrc1Color0
+*/
+
+/*!
+ \qmlproperty enumeration Qt3D.Render::BlendEquationArguments::sourceRgb
+
+ */
+
+/*!
+ \property Qt3DRender::QBlendEquationArguments::sourceRgb
+
+ */
+QBlendEquationArguments::Blending QBlendEquationArguments::sourceRgb() const
+{
+ Q_D(const QBlendEquationArguments);
+ return d->m_sourceRgb;
+}
+
+void QBlendEquationArguments::setSourceRgb(QBlendEquationArguments::Blending sourceRgb)
+{
+ Q_D(QBlendEquationArguments);
+ if (d->m_sourceRgb != sourceRgb) {
+ d->m_sourceRgb = sourceRgb;
+ emit sourceRgbChanged(sourceRgb);
+ }
+}
+
+/*!
+ \qmlproperty enumeration Qt3D.Render::BlendEquationArguments::destinationRgb
+
+ */
+
+/*!
+ \property Qt3DRender::QBlendEquationArguments::destinationRgb
+
+ */
+QBlendEquationArguments::Blending QBlendEquationArguments::destinationRgb() const
+{
+ Q_D(const QBlendEquationArguments);
+ return d->m_destinationRgb;
+}
+
+void QBlendEquationArguments::setDestinationRgb(QBlendEquationArguments::Blending destinationRgb)
+{
+ Q_D(QBlendEquationArguments);
+ if (d->m_destinationRgb != destinationRgb) {
+ d->m_destinationRgb = destinationRgb;
+ emit destinationRgbChanged(destinationRgb);
+ }
+}
+
+/*!
+ \qmlproperty enumeration Qt3D.Render::BlendEquationArguments::sourceAlpha
+
+ */
+
+/*!
+ \property Qt3DRender::QBlendEquationArguments::sourceAlpha
+
+ */
+QBlendEquationArguments::Blending QBlendEquationArguments::sourceAlpha() const
+{
+ Q_D(const QBlendEquationArguments);
+ return d->m_sourceAlpha;
+}
+
+void QBlendEquationArguments::setSourceAlpha(QBlendEquationArguments::Blending sourceAlpha)
+{
+ Q_D(QBlendEquationArguments);
+ if (d->m_sourceAlpha != sourceAlpha) {
+ d->m_sourceAlpha = sourceAlpha;
+ emit sourceAlphaChanged(sourceAlpha);
+ }
+}
+
+/*!
+ \qmlproperty enumeration Qt3D.Render::BlendEquationArguments::DestinationAlpha
+
+ */
+
+/*!
+ \property Qt3DRender::QBlendEquationArguments::destinationAlpha
+
+ */
+QBlendEquationArguments::Blending QBlendEquationArguments::destinationAlpha() const
+{
+ Q_D(const QBlendEquationArguments);
+ return d->m_destinationAlpha;
+}
+
+void QBlendEquationArguments::setDestinationAlpha(QBlendEquationArguments::Blending destinationAlpha)
+{
+ Q_D(QBlendEquationArguments);
+ if (d->m_destinationAlpha != destinationAlpha) {
+ d->m_destinationAlpha = destinationAlpha;
+ emit destinationAlphaChanged(destinationAlpha);
+ }
+}
+
+/*!
+ \qmlproperty int Qt3D.Render::BlendEquationArguments::bufferIndex
+
+ Specifies the index of the Draw Buffer that this BlendEquationArguments applies to.
+ If negative, this will apply to all Draw Buffers.
+ */
+
+/*!
+ \property Qt3DRender::QBlendEquationArguments::bufferIndex
+
+ Specifies the index of the Draw Buffer that this BlendEquationArguments applies to.
+ If negative, this will apply to all Draw Buffers.
+ */
+int QBlendEquationArguments::bufferIndex() const
+{
+ Q_D(const QBlendEquationArguments);
+ return d->m_bufferIndex;
+}
+
+void QBlendEquationArguments::setBufferIndex(int bufferIndex)
+{
+ Q_D(QBlendEquationArguments);
+ if (d->m_bufferIndex != bufferIndex) {
+ d->m_bufferIndex = bufferIndex;
+ emit bufferIndexChanged(bufferIndex);
+ }
+}
+
+/*!
+ \class Qt3DRender::QBlendSeparate
+ \inmodule Qt3DRender
+ \since 5.5
+ \brief Encapsulates blending information.
+ */
+
+/*!
+ \qmltype BlendStateSeparate
+ \instantiates Qt3DRender::QBlendStateSeparate
+ \inherits RenderState
+ \inqmlmodule Qt3D.Render
+ \since 5.5
+ \brief Encapsulates blending information.
+*/
+
+/*!
+ The constructor creates a QBlendStateSeparate instance with the
+ specified \a parent.
+ */
+QBlendStateSeparate::QBlendStateSeparate(QNode *parent)
+ : QBlendEquationArguments(QRenderState::BlendStateSeparate, parent)
+{
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/renderstates/qblendstate.h b/src/render/renderstates/qblendequationarguments.h
index f57bd6ddb..0403e9d7b 100644
--- a/src/render/renderstates/qblendstate.h
+++ b/src/render/renderstates/qblendequationarguments.h
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#ifndef QT3DRENDER_QBLENDSTATE_H
-#define QT3DRENDER_QBLENDSTATE_H
+#ifndef QT3DRENDER_QBLENDEQUATIONARGUMENTS_H
+#define QT3DRENDER_QBLENDEQUATIONARGUMENTS_H
#include <Qt3DRender/qrenderstate.h>
@@ -47,16 +47,15 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QBlendStatePrivate;
+class QBlendEquationArgumentsPrivate;
-class QT3DRENDERSHARED_EXPORT QBlendState : public QRenderState
+class QT3DRENDERSHARED_EXPORT QBlendEquationArguments : public QRenderState
{
Q_OBJECT
- Q_PROPERTY(Blending srcRGB READ srcRGB WRITE setSrcRGB NOTIFY srcRGBChanged)
- Q_PROPERTY(Blending srcAlpha READ srcAlpha WRITE setSrcAlpha NOTIFY srcAlphaChanged)
- Q_PROPERTY(Blending dstRGB READ dstRGB WRITE setDstRGB NOTIFY dstRGBChanged)
- Q_PROPERTY(Blending dstAlpha READ dstAlpha WRITE setDstAlpha NOTIFY dstAlphaChanged)
- Q_PROPERTY(bool specifiesAllDrawBuffers READ specifiesAllDrawBuffers NOTIFY specifiesAllDrawBuffersChanged)
+ Q_PROPERTY(Blending sourceRgb READ sourceRgb WRITE setSourceRgb NOTIFY sourceRgbChanged)
+ Q_PROPERTY(Blending sourceAlpha READ sourceAlpha WRITE setSourceAlpha NOTIFY sourceAlphaChanged)
+ Q_PROPERTY(Blending destinationRgb READ destinationRgb WRITE setDestinationRgb NOTIFY destinationRgbChanged)
+ Q_PROPERTY(Blending destinationAlpha READ destinationAlpha WRITE setDestinationAlpha NOTIFY destinationAlphaChanged)
Q_PROPERTY(int bufferIndex READ bufferIndex WRITE setBufferIndex NOTIFY bufferIndexChanged)
public:
@@ -65,61 +64,60 @@ public:
{
Zero = 0,
One = 1,
- SrcColor = 0x0300,
- SrcAlpha = 0x0302,
- Src1Alpha,
- Src1Color,
- DstColor = 0x0306,
- DstAlpha = 0x0304,
- SrcAlphaSaturate = 0x0308,
+ SourceColor = 0x0300,
+ SourceAlpha = 0x0302,
+ Source1Alpha,
+ Source1Color,
+ DestinationColor = 0x0306,
+ DestinationAlpha = 0x0304,
+ SourceAlphaSaturate = 0x0308,
ConstantColor = 0x8001,
ConstantAlpha = 0x8003,
- OneMinusSrcColor = 0x0301,
- OneMinusSrcAlpha = 0x0303,
- OneMinusDstAlpha = 0x0305,
- OneMinusDstColor = 0x0307,
+ OneMinusSourceColor = 0x0301,
+ OneMinusSourceAlpha = 0x0303,
+ OneMinusDestinationAlpha = 0x0305,
+ OneMinusDestinationColor = 0x0307,
OneMinusConstantColor = 0x8002,
OneMinusConstantAlpha = 0x8004,
- OneMinusSrc1Alpha,
- OneMinusSrc1Color0
+ OneMinusSource1Alpha,
+ OneMinusSource1Color0
};
Q_ENUM(Blending)
- explicit QBlendState(Qt3DCore::QNode *parent = 0);
- ~QBlendState();
+ explicit QBlendEquationArguments(Qt3DCore::QNode *parent = 0);
+ ~QBlendEquationArguments();
- Blending srcRGB() const;
- Blending dstRGB() const;
- Blending srcAlpha() const;
- Blending dstAlpha() const;
+ Blending sourceRgb() const;
+ Blending destinationRgb() const;
+ Blending sourceAlpha() const;
+ Blending destinationAlpha() const;
int bufferIndex() const;
bool specifiesAllDrawBuffers() const;
public Q_SLOTS:
- void setSrcRGB(Blending srcRGB);
- void setDstRGB(Blending dstRGB);
- void setSrcAlpha(Blending srcAlpha);
- void setDstAlpha(Blending dstAlpha);
+ void setSourceRgb(Blending sourceRgb);
+ void setDestinationRgb(Blending destinationRgb);
+ void setSourceAlpha(Blending sourceAlpha);
+ void setDestinationAlpha(Blending destinationAlpha);
void setBufferIndex(int index);
Q_SIGNALS:
- void srcRGBChanged(Blending srcRGB);
- void srcAlphaChanged(Blending srcAlpha);
- void dstRGBChanged(Blending dstRGB);
- void dstAlphaChanged(Blending dstAlpha);
+ void sourceRgbChanged(Blending sourceRgb);
+ void sourceAlphaChanged(Blending sourceAlpha);
+ void destinationRgbChanged(Blending destinationRgb);
+ void destinationAlphaChanged(Blending destinationAlpha);
void bufferIndexChanged(int index);
- void specifiesAllDrawBuffersChanged(bool specifyAll);
protected:
void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
- QBlendState(QRenderState::Type type, Qt3DCore::QNode *parent = 0);
+ QBlendEquationArguments(QRenderState::Type type, Qt3DCore::QNode *parent = 0);
private:
- Q_DECLARE_PRIVATE(QBlendState)
- QT3D_CLONEABLE(QBlendState)
+ Q_DECLARE_PRIVATE(QBlendEquationArguments)
+ QT3D_CLONEABLE(QBlendEquationArguments)
};
-class QT3DRENDERSHARED_EXPORT QBlendStateSeparate : public QBlendState
+class QT3DRENDERSHARED_EXPORT QBlendStateSeparate : public QBlendEquationArguments
{
Q_OBJECT
public:
@@ -130,4 +128,4 @@ public:
QT_END_NAMESPACE
-#endif // QT3DRENDER_QBLENDSTATE_H
+#endif // QT3DRENDER_QBLENDEQUATIONARGUMENTS_H
diff --git a/src/render/renderstates/qblendstate.cpp b/src/render/renderstates/qblendstate.cpp
deleted file mode 100644
index 492c533ce..000000000
--- a/src/render/renderstates/qblendstate.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** 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 "qblendstate.h"
-#include "qrenderstate_p.h"
-#include <Qt3DCore/qscenepropertychange.h>
-#include <private/qnode_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-
-class QBlendStatePrivate : public QRenderStatePrivate
-{
-public:
- QBlendStatePrivate(QRenderState::Type type = QRenderState::BlendState)
- : QRenderStatePrivate(type)
- , m_srcRGB(QBlendState::Zero)
- , m_srcAlpha(QBlendState::Zero)
- , m_dstRGB(QBlendState::Zero)
- , m_dstAlpha(QBlendState::Zero)
- , m_bufferIndex(-1)
- {
- }
-
- Q_DECLARE_PUBLIC(QBlendState)
-
- QBlendState::Blending m_srcRGB;
- QBlendState::Blending m_srcAlpha;
- QBlendState::Blending m_dstRGB;
- QBlendState::Blending m_dstAlpha;
- int m_bufferIndex;
-};
-
-/*!
- \class Qt3DRender::QBlendState
- \inmodule Qt3DRender
- \since 5.5
- \brief Encapsulates blending information.
-
- OpenGL pre-3.0: Set the same blend state for all draw buffers
- (one QBlendState)
- OpenGL 3.0-pre4.0: Set the same blend state for all draw buffers,
- but can disable blending for particular buffers
- (one QBlendState for setting glBlendFunc, n QBlendStates
- for enabling/disabling Draw Buffers)
- OpenGL 4.0+: Can set blend state individually for each draw buffer.
- */
-
-/*!
- \qmltype BlendState
- \instantiates Qt3DRender::QBlendState
- \inherits RenderState
- \inqmlmodule Qt3D.Render
- \since 5.5
- \brief Encapsulates blending information.
-
- OpenGL pre-3.0: Set the same blend state for all draw buffers
- OpenGL 3.0-pre4.0: Set the same blend state for all draw buffers,
- but can disable blending for particular buffers
- OpenGL 4.0+: Can set blend state individually for each draw buffer.
-*/
-
-/*!
- The constructor creates a new blend state object with the specified \a parent.
- */
-QBlendState::QBlendState(QNode *parent)
- : QRenderState(*new QBlendStatePrivate, parent)
-{
-}
-
-QBlendState::~QBlendState()
-{
- QNode::cleanup();
-}
-
-/*! \fn void QBlendState::copy(const Qt3DCore::QNode *ref)
- \internal
- Copies \a ref into this object.
- */
-void QBlendState::copy(const QNode *ref)
-{
- QRenderState::copy(ref);
- const QBlendState *refState = static_cast<const QBlendState*>(ref);
- d_func()->m_srcRGB = refState->d_func()->m_srcRGB;
- d_func()->m_srcAlpha = refState->d_func()->m_srcAlpha;
- d_func()->m_dstAlpha = refState->d_func()->m_dstAlpha;
- d_func()->m_dstRGB = refState->d_func()->m_dstRGB;
- d_func()->m_bufferIndex = refState->d_func()->m_bufferIndex;
-}
-
-/*!
- \internal
-*/
-QBlendState::QBlendState(QRenderState::Type type, QNode *parent)
- : QRenderState(*new QBlendStatePrivate(type), parent)
-{
-}
-
-/*!
- \enum Qt3DRender::QBlendState::Blending
-
- \value Zero 0
- \value One 1
- \value SrcColor 0x0300
- \value SrcAlpha 0x0302
- \value Src1Alpha
- \value Src1Color
- \value DstColor 0x0306
- \value DstAlpha 0x0304
- \value SrcAlphaSaturate 0x0308
- \value ConstantColor 0x8001
- \value ConstantAlpha 0x8003
- \value OneMinusSrcColor 0x0301
- \value OneMinusSrcAlpha 0x0303
- \value OneMinusDstAlpha 0x0305
- \value OneMinusDstColor 0x0307
- \value OneMinusConstantColor 0x8002
- \value OneMinusConstantAlpha 0x8004
- \value OneMinusSrc1Alpha
- \value OneMinusSrc1Color0
-*/
-
-/*!
- \qmlproperty enumeration Qt3D.Render::BlendState::srcRGB
-
- */
-
-/*!
- \property Qt3DRender::QBlendState::srcRGB
-
- */
-QBlendState::Blending QBlendState::srcRGB() const
-{
- Q_D(const QBlendState);
- return d->m_srcRGB;
-}
-
-void QBlendState::setSrcRGB(QBlendState::Blending srcRGB)
-{
- Q_D(QBlendState);
- if (d->m_srcRGB != srcRGB) {
- d->m_srcRGB = srcRGB;
- emit srcRGBChanged(srcRGB);
- }
-}
-
-/*!
- \qmlproperty enumeration Qt3D.Render::BlendState::dstRGB
-
- */
-
-/*!
- \property Qt3DRender::QBlendState::dstRGB
-
- */
-QBlendState::Blending QBlendState::dstRGB() const
-{
- Q_D(const QBlendState);
- return d->m_dstRGB;
-}
-
-void QBlendState::setDstRGB(QBlendState::Blending dstRGB)
-{
- Q_D(QBlendState);
- if (d->m_dstRGB != dstRGB) {
- d->m_dstRGB = dstRGB;
- emit dstRGBChanged(dstRGB);
- }
-}
-
-/*!
- \qmlproperty enumeration Qt3D.Render::BlendState::srcAlpha
-
- */
-
-/*!
- \property Qt3DRender::QBlendState::srcAlpha
-
- */
-QBlendState::Blending QBlendState::srcAlpha() const
-{
- Q_D(const QBlendState);
- return d->m_srcAlpha;
-}
-
-void QBlendState::setSrcAlpha(QBlendState::Blending srcAlpha)
-{
- Q_D(QBlendState);
- if (d->m_srcAlpha != srcAlpha) {
- d->m_srcAlpha = srcAlpha;
- emit srcAlphaChanged(srcAlpha);
- }
-}
-
-/*!
- \qmlproperty enumeration Qt3D.Render::BlendState::dstAlpha
-
- */
-
-/*!
- \property Qt3DRender::QBlendState::dstAlpha
-
- */
-QBlendState::Blending QBlendState::dstAlpha() const
-{
- Q_D(const QBlendState);
- return d->m_dstAlpha;
-}
-
-void QBlendState::setDstAlpha(QBlendState::Blending dstAlpha)
-{
- Q_D(QBlendState);
- if (d->m_dstAlpha != dstAlpha) {
- d->m_dstAlpha = dstAlpha;
- emit dstAlphaChanged(dstAlpha);
- }
-}
-
-/*!
- \qmlproperty int Qt3D.Render::BlendState::bufferIndex
-
- Specifies the index of the Draw Buffer that this BlendState applies to.
- If negative, this will apply to all Draw Buffers.
- */
-
-/*!
- \property Qt3DRender::QBlendState::bufferIndex
-
- Specifies the index of the Draw Buffer that this BlendState applies to.
- If negative, this will apply to all Draw Buffers.
- */
-int QBlendState::bufferIndex() const
-{
- Q_D(const QBlendState);
- return d->m_bufferIndex;
-}
-
-void QBlendState::setBufferIndex(int bufferIndex)
-{
- Q_D(QBlendState);
- if (d->m_bufferIndex != bufferIndex) {
- bool oldAllBuffers = (d->m_bufferIndex < 0);
- bool newAllBuffers = (bufferIndex < 0);
-
- d->m_bufferIndex = bufferIndex;
- emit bufferIndexChanged(bufferIndex);
-
- if (oldAllBuffers != newAllBuffers)
- emit specifiesAllDrawBuffersChanged(newAllBuffers);
- }
-}
-
-bool QBlendState::specifiesAllDrawBuffers() const
-{
- Q_D(const QBlendState);
- return (d->m_bufferIndex < 0);
-}
-
-/*!
- \class Qt3DRender::QBlendStateSeparate
- \inmodule Qt3DRender
- \since 5.5
- \brief Encapsulates blending information.
- */
-
-/*!
- \qmltype BlendStateSeparate
- \instantiates Qt3DRender::QBlendStateSeparate
- \inherits RenderState
- \inqmlmodule Qt3D.Render
- \since 5.5
- \brief Encapsulates blending information.
-*/
-
-/*!
- The constructor creates a QBlendStateSeparate instance with the
- specified \a parent.
- */
-QBlendStateSeparate::QBlendStateSeparate(QNode *parent)
- : QBlendState(QRenderState::BlendStateSeparate, parent)
-{
-}
-
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
diff --git a/src/render/renderstates/qrenderstate.h b/src/render/renderstates/qrenderstate.h
index 476144e16..65bdd53a4 100644
--- a/src/render/renderstates/qrenderstate.h
+++ b/src/render/renderstates/qrenderstate.h
@@ -59,7 +59,7 @@ public:
AlphaCoverage,
AlphaTest,
BlendEquation,
- BlendState,
+ BlendEquationArguments,
BlendStateSeparate,
ColorMask,
CullFace,
diff --git a/src/render/renderstates/renderstates.cpp b/src/render/renderstates/renderstates.cpp
index 2f5f95753..4340ef2f6 100644
--- a/src/render/renderstates/renderstates.cpp
+++ b/src/render/renderstates/renderstates.cpp
@@ -103,9 +103,9 @@ void RenderStateNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
}
}
-void BlendState::apply(GraphicsContext* gc) const
+void BlendEquationArguments::apply(GraphicsContext* gc) const
{
- // Un-indexed BlendState -> Use normal GL1.0 functions
+ // Un-indexed BlendEquationArguments -> Use normal GL1.0 functions
if (m_6 < 0) {
if (m_5) {
gc->openGLContext()->functions()->glEnable(GL_BLEND);
@@ -114,7 +114,7 @@ void BlendState::apply(GraphicsContext* gc) const
gc->openGLContext()->functions()->glDisable(GL_BLEND);
}
}
- // BlendState for a particular Draw Buffer. Different behaviours for
+ // BlendEquationArguments for a particular Draw Buffer. Different behaviours for
// (1) 3.0-3.3: only enablei/disablei supported.
// (2) 4.0+: all operations supported.
// We just ignore blend func parameter for (1), so no warnings get
@@ -131,12 +131,12 @@ void BlendState::apply(GraphicsContext* gc) const
}
}
-void BlendState::updateProperty(const char *name, const QVariant &value)
+void BlendEquationArguments::updateProperty(const char *name, const QVariant &value)
{
- if (name == QByteArrayLiteral("srcRGB")) m_1 = value.toInt();
- else if (name == QByteArrayLiteral("dstRGB")) m_2 = value.toInt();
- else if (name == QByteArrayLiteral("srcAlpha")) m_3 = value.toInt();
- else if (name == QByteArrayLiteral("dstAlphaB")) m_4 = value.toInt();
+ if (name == QByteArrayLiteral("sourceRgb")) m_1 = value.toInt();
+ else if (name == QByteArrayLiteral("destinationRgb")) m_2 = value.toInt();
+ else if (name == QByteArrayLiteral("sourceAlpha")) m_3 = value.toInt();
+ else if (name == QByteArrayLiteral("destinationAlpha")) m_4 = value.toInt();
else if (name == QByteArrayLiteral("enabled")) m_5 = value.toBool();
else if (name == QByteArrayLiteral("bufferIndex")) m_6 = value.toInt();
}
diff --git a/src/render/renderstates/renderstates.pri b/src/render/renderstates/renderstates.pri
index 897d8178d..880850837 100644
--- a/src/render/renderstates/renderstates.pri
+++ b/src/render/renderstates/renderstates.pri
@@ -5,7 +5,6 @@ HEADERS += \
$$PWD/qalphacoverage.h \
$$PWD/qalphatest.h \
$$PWD/qblendequation.h \
- $$PWD/qblendstate.h \
$$PWD/qclipplane.h \
$$PWD/qcolormask.h \
$$PWD/qcullface.h \
@@ -26,14 +25,14 @@ HEADERS += \
$$PWD/renderstateset_p.h \
$$PWD/qpointsize.h \
$$PWD/renderstatecollection_p.h \
- $$PWD/qseamlesscubemap.h
+ $$PWD/qseamlesscubemap.h \
+ $$PWD/qblendequationarguments.h
SOURCES += \
$$PWD/qalphacoverage.cpp \
$$PWD/qalphatest.cpp \
$$PWD/qblendequation.cpp \
- $$PWD/qblendstate.cpp \
$$PWD/qclipplane.cpp \
$$PWD/qcolormask.cpp \
$$PWD/qcullface.cpp \
@@ -53,4 +52,5 @@ SOURCES += \
$$PWD/renderstateset.cpp \
$$PWD/qpointsize.cpp \
$$PWD/renderstatecollection.cpp \
- $$PWD/qseamlesscubemap.cpp
+ $$PWD/qseamlesscubemap.cpp \
+ $$PWD/qblendequationarguments.cpp
diff --git a/src/render/renderstates/renderstates_p.h b/src/render/renderstates/renderstates_p.h
index 2c3fbe6d3..ae9d14bae 100644
--- a/src/render/renderstates/renderstates_p.h
+++ b/src/render/renderstates/renderstates_p.h
@@ -99,7 +99,7 @@ State* getOrCreateRenderStateImpl(const S& m1, const T& m2, const U& m3, const V
return getOrCreateRenderStateEqualTo<State>(state);
}
-class Q_AUTOTEST_EXPORT BlendState : public GenericState6<BlendState, BlendStateMask, GLenum, GLenum, GLenum, GLenum, bool, int>
+class Q_AUTOTEST_EXPORT BlendEquationArguments : public GenericState6<BlendEquationArguments, BlendStateMask, GLenum, GLenum, GLenum, GLenum, bool, int>
{
public:
virtual void apply(GraphicsContext *gc) const Q_DECL_OVERRIDE;
diff --git a/src/render/renderstates/renderstateset.cpp b/src/render/renderstates/renderstateset.cpp
index 8de1bcb46..0d324b55b 100644
--- a/src/render/renderstates/renderstateset.cpp
+++ b/src/render/renderstates/renderstateset.cpp
@@ -51,7 +51,7 @@
#include <Qt3DRender/qalphacoverage.h>
#include <Qt3DRender/qalphatest.h>
#include <Qt3DRender/qblendequation.h>
-#include <Qt3DRender/qblendstate.h>
+#include <Qt3DRender/qblendequationarguments.h>
#include <Qt3DRender/qcolormask.h>
#include <Qt3DRender/qcullface.h>
#include <Qt3DRender/qdepthmask.h>
@@ -268,18 +268,18 @@ RenderStateImpl* RenderStateImpl::getOrCreateState(QRenderState *renderState)
QBlendEquation *blendEquation = static_cast<QBlendEquation *>(renderState);
return getOrCreateRenderStateImpl<BlendEquation>(blendEquation->blendFunction());
}
- case QRenderState::BlendState: {
- QBlendState *blendState = static_cast<QBlendState *>(renderState);
+ case QRenderState::BlendEquationArguments: {
+ QBlendEquationArguments *blendState = static_cast<QBlendEquationArguments *>(renderState);
// just use the same values for RGB and Alpha
- return getOrCreateRenderStateImpl<BlendState>(blendState->srcRGB(), blendState->dstRGB(),
- blendState->srcRGB(), blendState->dstRGB(),
+ return getOrCreateRenderStateImpl<BlendEquationArguments>(blendState->sourceRgb(), blendState->destinationRgb(),
+ blendState->sourceRgb(), blendState->destinationRgb(),
blendState->isEnabled(),
blendState->bufferIndex());
}
case QRenderState::BlendStateSeparate: {
- QBlendState *blendState = static_cast<QBlendState *>(renderState);
- return getOrCreateRenderStateImpl<BlendState>(blendState->srcRGB(), blendState->dstRGB(),
- blendState->srcAlpha(), blendState->dstAlpha(),
+ QBlendEquationArguments *blendState = static_cast<QBlendEquationArguments *>(renderState);
+ return getOrCreateRenderStateImpl<BlendEquationArguments>(blendState->sourceRgb(), blendState->destinationRgb(),
+ blendState->sourceAlpha(), blendState->destinationAlpha(),
blendState->isEnabled(),
blendState->bufferIndex());
}