summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2016-04-07 21:22:31 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-04-11 08:00:15 +0000
commitdc58fc97ed9a36fa454eaa43e6f1cd7dc13a6d2d (patch)
tree925bf7fc16fba19ca975f0e92af1bb9a2ca35894
parent19a8c6b46cb538ee4e628cbe50f6fa549094d7eb (diff)
Properly handle alpha to coverage state in non-cloning codepath
Also improve the alpha to coverage handlign in the helpers by using a single function rather than two. This removes GL errors about bad glFace enum values (caused by bad handlign of alpha to coverage in switch statement, which led to a FrontFace state being created with bad data). Change-Id: I832d92fcb07134525f421d3a3b4d12e9f5f6428c Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/render/graphicshelpers/graphicscontext.cpp9
-rw-r--r--src/render/graphicshelpers/graphicscontext_p.h3
-rw-r--r--src/render/graphicshelpers/graphicshelperes2.cpp10
-rw-r--r--src/render/graphicshelpers/graphicshelperes2_p.h3
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2.cpp10
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2_p.h3
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3.cpp10
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_3.cpp10
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_3_p.h3
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_p.h3
-rw-r--r--src/render/graphicshelpers/graphicshelpergl4.cpp10
-rw-r--r--src/render/graphicshelpers/graphicshelpergl4_p.h3
-rw-r--r--src/render/graphicshelpers/graphicshelperinterface_p.h3
-rw-r--r--src/render/renderstates/renderstates.cpp8
-rw-r--r--src/render/renderstates/renderstates_p.h3
-rw-r--r--src/render/renderstates/renderstateset.cpp9
16 files changed, 39 insertions, 61 deletions
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp
index 3d387be66..1600f24e6 100644
--- a/src/render/graphicshelpers/graphicscontext.cpp
+++ b/src/render/graphicshelpers/graphicscontext.cpp
@@ -832,14 +832,9 @@ void GraphicsContext::buildUniformBuffer(const QVariant &v, const ShaderUniform
m_glHelper->buildUniformBuffer(v, description, buffer);
}
-void GraphicsContext::enableAlphaCoverage()
+void GraphicsContext::setAlphaCoverageEnabled(bool enabled)
{
- m_glHelper->enableAlphaCoverage();
-}
-
-void GraphicsContext::disableAlphaCoverage()
-{
- m_glHelper->disableAlphaCoverage();
+ m_glHelper->setAlphaCoverageEnabled(enabled);
}
GLuint GraphicsContext::boundFrameBufferObject()
diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h
index ea6db02ed..d00292cb4 100644
--- a/src/render/graphicshelpers/graphicscontext_p.h
+++ b/src/render/graphicshelpers/graphicscontext_p.h
@@ -192,7 +192,6 @@ public:
void cullFace(GLenum mode);
void depthMask(GLenum mode);
void depthTest(GLenum mode);
- void disableAlphaCoverage();
void disableClipPlane(int clipPlane);
void disablei(GLenum cap, GLuint index);
void disablePrimitiveRestart();
@@ -201,13 +200,13 @@ public:
void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances);
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0);
void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0);
- void enableAlphaCoverage();
void enableClipPlane(int clipPlane);
void enablei(GLenum cap, GLuint index);
void enablePrimitiveRestart(int restartIndex);
void frontFace(GLenum mode);
GLint maxClipPlaneCount();
void pointSize(bool programmable, GLfloat value);
+ void setAlphaCoverageEnabled(bool enabled);
void setClipPlane(int clipPlane, const QVector3D &normal, float distance);
void setSeamlessCubemap(bool enable);
void setVerticesPerPatch(GLint verticesPerPatch);
diff --git a/src/render/graphicshelpers/graphicshelperes2.cpp b/src/render/graphicshelpers/graphicshelperes2.cpp
index 32bc703f1..cc8de52ed 100644
--- a/src/render/graphicshelpers/graphicshelperes2.cpp
+++ b/src/render/graphicshelpers/graphicshelperes2.cpp
@@ -277,14 +277,10 @@ void GraphicsHelperES2::frontFace(GLenum mode)
m_funcs->glFrontFace(mode);
}
-void GraphicsHelperES2::enableAlphaCoverage()
+void GraphicsHelperES2::setAlphaCoverageEnabled(bool enabled)
{
- m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-void GraphicsHelperES2::disableAlphaCoverage()
-{
- m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+ enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
+ : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
GLuint GraphicsHelperES2::createFrameBufferObject()
diff --git a/src/render/graphicshelpers/graphicshelperes2_p.h b/src/render/graphicshelpers/graphicshelperes2_p.h
index 1ef56d1f2..f5273a25a 100644
--- a/src/render/graphicshelpers/graphicshelperes2_p.h
+++ b/src/render/graphicshelpers/graphicshelperes2_p.h
@@ -85,7 +85,6 @@ public:
void cullFace(GLenum mode) Q_DECL_OVERRIDE;
void depthMask(GLenum mode) Q_DECL_OVERRIDE;
void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void disablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void disablePrimitiveRestart() Q_DECL_OVERRIDE;
@@ -95,7 +94,6 @@ public:
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
@@ -110,6 +108,7 @@ public:
QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) Q_DECL_OVERRIDE;
void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setAlphaCoverageEnabled(bool enable) Q_DECL_OVERRIDE;
void setClipPlane(int clipPlane, const QVector3D &normal, float distance) Q_DECL_OVERRIDE;
void setSeamlessCubemap(bool enable) Q_DECL_OVERRIDE;
void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelpergl2.cpp b/src/render/graphicshelpers/graphicshelpergl2.cpp
index 2c0bd1ec9..2a77982d9 100644
--- a/src/render/graphicshelpers/graphicshelpergl2.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl2.cpp
@@ -260,14 +260,10 @@ void GraphicsHelperGL2::frontFace(GLenum mode)
m_funcs->glFrontFace(mode);
}
-void GraphicsHelperGL2::enableAlphaCoverage()
+void GraphicsHelperGL2::setAlphaCoverageEnabled(bool enabled)
{
- m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-void GraphicsHelperGL2::disableAlphaCoverage()
-{
- m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+ enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
+ : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
GLuint GraphicsHelperGL2::createFrameBufferObject()
diff --git a/src/render/graphicshelpers/graphicshelpergl2_p.h b/src/render/graphicshelpers/graphicshelpergl2_p.h
index e5e92c96c..a928f3be7 100644
--- a/src/render/graphicshelpers/graphicshelpergl2_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl2_p.h
@@ -87,7 +87,6 @@ public:
void cullFace(GLenum mode) Q_DECL_OVERRIDE;
void depthMask(GLenum mode) Q_DECL_OVERRIDE;
void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void disablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void disablePrimitiveRestart() Q_DECL_OVERRIDE;
@@ -97,7 +96,6 @@ public:
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
@@ -112,6 +110,7 @@ public:
QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) Q_DECL_OVERRIDE;
void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setAlphaCoverageEnabled(bool enable) Q_DECL_OVERRIDE;
void setClipPlane(int clipPlane, const QVector3D &normal, float distance) Q_DECL_OVERRIDE;
void setSeamlessCubemap(bool enable) Q_DECL_OVERRIDE;
void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelpergl3.cpp b/src/render/graphicshelpers/graphicshelpergl3.cpp
index 0eee70456..2b44bc3da 100644
--- a/src/render/graphicshelpers/graphicshelpergl3.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl3.cpp
@@ -308,14 +308,10 @@ void GraphicsHelperGL3::frontFace(GLenum mode)
}
-void GraphicsHelperGL3::enableAlphaCoverage()
+void GraphicsHelperGL3::setAlphaCoverageEnabled(bool enabled)
{
- m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-void GraphicsHelperGL3::disableAlphaCoverage()
-{
- m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+ enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
+ : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
GLuint GraphicsHelperGL3::createFrameBufferObject()
diff --git a/src/render/graphicshelpers/graphicshelpergl3_3.cpp b/src/render/graphicshelpers/graphicshelpergl3_3.cpp
index c66ad601c..70c7cf53e 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_3.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl3_3.cpp
@@ -305,14 +305,10 @@ void GraphicsHelperGL3_3::frontFace(GLenum mode)
}
-void GraphicsHelperGL3_3::enableAlphaCoverage()
+void GraphicsHelperGL3_3::setAlphaCoverageEnabled(bool enabled)
{
- m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-void GraphicsHelperGL3_3::disableAlphaCoverage()
-{
- m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+ enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
+ : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
GLuint GraphicsHelperGL3_3::createFrameBufferObject()
diff --git a/src/render/graphicshelpers/graphicshelpergl3_3_p.h b/src/render/graphicshelpers/graphicshelpergl3_3_p.h
index 7509a91fc..d84a9ed72 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_3_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl3_3_p.h
@@ -88,7 +88,6 @@ public:
void cullFace(GLenum mode) Q_DECL_OVERRIDE;
void depthMask(GLenum mode) Q_DECL_OVERRIDE;
void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void disablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void disablePrimitiveRestart() Q_DECL_OVERRIDE;
@@ -98,7 +97,6 @@ public:
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
@@ -113,6 +111,7 @@ public:
QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) Q_DECL_OVERRIDE;
void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setAlphaCoverageEnabled(bool enable) Q_DECL_OVERRIDE;
void setClipPlane(int clipPlane, const QVector3D &normal, float distance) Q_DECL_OVERRIDE;
void setSeamlessCubemap(bool enable) Q_DECL_OVERRIDE;
void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelpergl3_p.h b/src/render/graphicshelpers/graphicshelpergl3_p.h
index c55a27637..49843055e 100644
--- a/src/render/graphicshelpers/graphicshelpergl3_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl3_p.h
@@ -88,7 +88,6 @@ public:
void cullFace(GLenum mode) Q_DECL_OVERRIDE;
void depthMask(GLenum mode) Q_DECL_OVERRIDE;
void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void disablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void disablePrimitiveRestart() Q_DECL_OVERRIDE;
@@ -98,7 +97,6 @@ public:
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
@@ -113,6 +111,7 @@ public:
QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) Q_DECL_OVERRIDE;
void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setAlphaCoverageEnabled(bool enable) Q_DECL_OVERRIDE;
void setClipPlane(int clipPlane, const QVector3D &normal, float distance) Q_DECL_OVERRIDE;
void setSeamlessCubemap(bool enable) Q_DECL_OVERRIDE;
void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelpergl4.cpp b/src/render/graphicshelpers/graphicshelpergl4.cpp
index 066603ab4..7e04d7a6c 100644
--- a/src/render/graphicshelpers/graphicshelpergl4.cpp
+++ b/src/render/graphicshelpers/graphicshelpergl4.cpp
@@ -298,14 +298,10 @@ void GraphicsHelperGL4::frontFace(GLenum mode)
}
-void GraphicsHelperGL4::enableAlphaCoverage()
+void GraphicsHelperGL4::setAlphaCoverageEnabled(bool enabled)
{
- m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-}
-
-void GraphicsHelperGL4::disableAlphaCoverage()
-{
- m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+ enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
+ : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
GLuint GraphicsHelperGL4::createFrameBufferObject()
diff --git a/src/render/graphicshelpers/graphicshelpergl4_p.h b/src/render/graphicshelpers/graphicshelpergl4_p.h
index 0ab3ef5db..81553abc3 100644
--- a/src/render/graphicshelpers/graphicshelpergl4_p.h
+++ b/src/render/graphicshelpers/graphicshelpergl4_p.h
@@ -87,7 +87,6 @@ public:
void cullFace(GLenum mode) Q_DECL_OVERRIDE;
void depthMask(GLenum mode) Q_DECL_OVERRIDE;
void depthTest(GLenum mode) Q_DECL_OVERRIDE;
- void disableAlphaCoverage() Q_DECL_OVERRIDE;
void disableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void disablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void disablePrimitiveRestart() Q_DECL_OVERRIDE;
@@ -97,7 +96,6 @@ public:
void drawBuffers(GLsizei n, const int *bufs) Q_DECL_OVERRIDE;
void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLint baseVertex = 0) Q_DECL_OVERRIDE;
void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void *indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) Q_DECL_OVERRIDE;
- void enableAlphaCoverage() Q_DECL_OVERRIDE;
void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE;
void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE;
void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE;
@@ -112,6 +110,7 @@ public:
QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) Q_DECL_OVERRIDE;
QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) Q_DECL_OVERRIDE;
void releaseFrameBufferObject(GLuint frameBufferId) Q_DECL_OVERRIDE;
+ void setAlphaCoverageEnabled(bool enable) Q_DECL_OVERRIDE;
void setClipPlane(int clipPlane, const QVector3D &normal, float distance) Q_DECL_OVERRIDE;
void setSeamlessCubemap(bool enable) Q_DECL_OVERRIDE;
void setVerticesPerPatch(GLint verticesPerPatch) Q_DECL_OVERRIDE;
diff --git a/src/render/graphicshelpers/graphicshelperinterface_p.h b/src/render/graphicshelpers/graphicshelperinterface_p.h
index 584b68475..9f508876a 100644
--- a/src/render/graphicshelpers/graphicshelperinterface_p.h
+++ b/src/render/graphicshelpers/graphicshelperinterface_p.h
@@ -98,7 +98,6 @@ public:
virtual void cullFace(GLenum mode) = 0;
virtual void depthMask(GLenum mode) = 0;
virtual void depthTest(GLenum mode) = 0;
- virtual void disableAlphaCoverage() = 0;
virtual void disableClipPlane(int clipPlane) = 0;
virtual void disablei(GLenum cap, GLuint index) = 0;
virtual void disablePrimitiveRestart() = 0;
@@ -108,7 +107,6 @@ public:
virtual void drawBuffers(GLsizei n, const int *bufs) = 0;
virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex = 0) = 0;
virtual void drawElementsInstanced(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex = 0, GLint baseInstance = 0) = 0;
- virtual void enableAlphaCoverage() = 0;
virtual void enableClipPlane(int clipPlane) = 0;
virtual void enablei(GLenum cap, GLuint index) = 0;
virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0;
@@ -123,6 +121,7 @@ public:
virtual QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) = 0;
virtual QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) = 0;
virtual void releaseFrameBufferObject(GLuint frameBufferId) = 0;
+ virtual void setAlphaCoverageEnabled(bool enable) = 0;
virtual void setClipPlane(int clipPlane, const QVector3D &normal, float distance) = 0;
virtual void setSeamlessCubemap(bool enable) = 0;
virtual void setVerticesPerPatch(GLint verticesPerPatch) = 0;
diff --git a/src/render/renderstates/renderstates.cpp b/src/render/renderstates/renderstates.cpp
index 94e272cdd..bc84d9779 100644
--- a/src/render/renderstates/renderstates.cpp
+++ b/src/render/renderstates/renderstates.cpp
@@ -182,7 +182,13 @@ void StencilTest::apply(GraphicsContext *gc) const
void AlphaCoverage::apply(GraphicsContext *gc) const
{
- gc->enableAlphaCoverage();
+ gc->setAlphaCoverageEnabled(m_1);
+}
+
+void AlphaCoverage::updateProperty(const char *name, const QVariant &value)
+{
+ if (name == QByteArrayLiteral("enabled"))
+ m_1 = value.toBool();
}
void PointSize::apply(GraphicsContext *gc) const
diff --git a/src/render/renderstates/renderstates_p.h b/src/render/renderstates/renderstates_p.h
index aed7e2ee1..308f1957b 100644
--- a/src/render/renderstates/renderstates_p.h
+++ b/src/render/renderstates/renderstates_p.h
@@ -168,10 +168,11 @@ public:
virtual void apply(GraphicsContext *gc) const Q_DECL_OVERRIDE;
};
-class Q_AUTOTEST_EXPORT AlphaCoverage : public MaskedRenderState<AlphaCoverage, AlphaCoverageStateMask>
+class Q_AUTOTEST_EXPORT AlphaCoverage : public GenericState1<AlphaCoverage, AlphaCoverageStateMask, GLboolean>
{
public:
void apply(GraphicsContext *gc) const Q_DECL_OVERRIDE;
+ void updateProperty(const char *name, const QVariant &value) Q_DECL_OVERRIDE;
};
class Q_AUTOTEST_EXPORT PointSize : public GenericState2<PointSize, PointSizeMask, bool, GLfloat>
diff --git a/src/render/renderstates/renderstateset.cpp b/src/render/renderstates/renderstateset.cpp
index 187017ddb..d68600aeb 100644
--- a/src/render/renderstates/renderstateset.cpp
+++ b/src/render/renderstates/renderstateset.cpp
@@ -229,7 +229,7 @@ void RenderStateSet::resetMasked(StateMaskSet maskOfStatesToReset, GraphicsConte
}
if (maskOfStatesToReset & AlphaCoverageStateMask) {
- gc->disableAlphaCoverage();
+ gc->setAlphaCoverageEnabled(false);
}
if (maskOfStatesToReset & PointSizeMask) {
@@ -374,6 +374,10 @@ RenderStateImpl* RenderStateImpl::getOrCreateState(QRenderState *renderState)
RenderStateImpl* RenderStateImpl::getOrCreateState(const Qt3DRender::QRenderStateCreatedChangeBasePtr change)
{
switch (change->type()) {
+ case QRenderStatePrivate::AlphaCoverage: {
+ return getOrCreateRenderStateImpl<AlphaCoverage>(change->isNodeEnabled());
+ }
+
case QRenderStatePrivate::AlphaTest: {
const auto typedChange = qSharedPointerCast<Qt3DRender::QRenderStateCreatedChange<QAlphaTestData>>(change);
const auto &data = typedChange->data;
@@ -412,8 +416,7 @@ RenderStateImpl* RenderStateImpl::getOrCreateState(const Qt3DRender::QRenderStat
return getOrCreateRenderStateImpl<DepthTest>(data.depthFunction);
}
- // TODO: Fix AlphaCoverage and Dithering states
- case QRenderStatePrivate::AlphaCoverage:
+ // TODO: Fix Dithering state
case QRenderStatePrivate::Dithering:
case QRenderStatePrivate::FrontFace: {
const auto typedChange = qSharedPointerCast<Qt3DRender::QRenderStateCreatedChange<QFrontFaceData>>(change);