summaryrefslogtreecommitdiffstats
path: root/src/render/renderstates/qblendstate.cpp
diff options
context:
space:
mode:
authorWieland Hagen <wieland.hagen@kdab.com>2016-01-14 18:18:35 +0100
committerWieland Hagen <wieland.hagen@kdab.com>2016-01-15 13:02:47 +0000
commit4a93090a7b51da4a1e9f66d9727003fac0df53ac (patch)
treef0584b66f9b83ff2ed80fec174146d4c491eac63 /src/render/renderstates/qblendstate.cpp
parent0f50b649912d44eb75e37a3f17afcefbec40fba7 (diff)
QBlendState: Target particular Draw Buffers (glBlendFunci())
There are 3 ways blending can be configured, depending on GL version: pre-3.0: Globally 3.0-3.3: Individual GL_BLEND for each Draw Buffer, one glBlendFunc 4.0- : Individual GL_BLEND and glBlendFunci for each DrawBuffer QBlendStates now allow to specify whether the blend state should be enabled or not, and what Draw Buffer it is specifying. Defaults are global and enabled. Removed backend BlendStateSeparate, BlendState is going to handle both calls. Task-number: QTBUG-50005 Change-Id: I0059a53db0d629ef9818d933c3f14e5662c1d3df Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/renderstates/qblendstate.cpp')
-rw-r--r--src/render/renderstates/qblendstate.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/render/renderstates/qblendstate.cpp b/src/render/renderstates/qblendstate.cpp
index 0a27c5b35..a92409118 100644
--- a/src/render/renderstates/qblendstate.cpp
+++ b/src/render/renderstates/qblendstate.cpp
@@ -53,6 +53,8 @@ public:
, m_srcAlpha(QBlendState::Zero)
, m_dstRGB(QBlendState::Zero)
, m_dstAlpha(QBlendState::Zero)
+ , m_enabled(true)
+ , m_bufferIndex(-1)
{
}
@@ -62,6 +64,8 @@ public:
QBlendState::Blending m_srcAlpha;
QBlendState::Blending m_dstRGB;
QBlendState::Blending m_dstAlpha;
+ bool m_enabled;
+ int m_bufferIndex;
};
/*!
@@ -69,6 +73,14 @@ public:
\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.
*/
/*!
@@ -78,6 +90,11 @@ public:
\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.
*/
/*!
@@ -105,6 +122,8 @@ void QBlendState::copy(const QNode *ref)
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_enabled = refState->d_func()->m_enabled;
+ d_func()->m_bufferIndex = refState->d_func()->m_bufferIndex;
}
/*!
@@ -235,6 +254,61 @@ void QBlendState::setDstAlpha(QBlendState::Blending dstAlpha)
}
}
+bool QBlendState::enabled() const
+{
+ Q_D(const QBlendState);
+ return d->m_enabled;
+}
+
+void QBlendState::setEnabled(bool enabled)
+{
+ Q_D(QBlendState);
+ if (d->m_enabled != enabled) {
+ d->m_enabled = enabled;
+ emit enabledChanged(enabled);
+ }
+}
+
+/*!
+ \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