diff options
author | Wieland Hagen <wieland.hagen@kdab.com> | 2016-04-14 20:08:23 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-04-16 12:22:20 +0000 |
commit | a91cbabb6447fb1a9f5702118eb3aa98f175918c (patch) | |
tree | ec204b96e05c4da6f7b24aa1af53d1b0cee113d5 | |
parent | caeb69e2401fe4e8e4d7dfa34e39eee941478a9e (diff) |
Add GraphicsContext support for glClearBufferfv()
Task-number: QTBUG-50116
Change-Id: I78e06b0e2846897e2edaa5711b4e0d4a8057a3fc
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
13 files changed, 44 insertions, 0 deletions
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp index 80ca4d658..2ed870d8d 100644 --- a/src/render/graphicshelpers/graphicscontext.cpp +++ b/src/render/graphicshelpers/graphicscontext.cpp @@ -832,6 +832,11 @@ void GraphicsContext::setAlphaCoverageEnabled(bool enabled) m_glHelper->setAlphaCoverageEnabled(enabled); } +void GraphicsContext::clearBufferf(GLint drawbuffer, const QVector4D &values) +{ + m_glHelper->clearBufferf(drawbuffer, values); +} + GLuint GraphicsContext::boundFrameBufferObject() { return m_glHelper->boundFrameBufferObject(); diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h index b21c94e20..c3ab61215 100644 --- a/src/render/graphicshelpers/graphicscontext_p.h +++ b/src/render/graphicshelpers/graphicscontext_p.h @@ -186,6 +186,7 @@ public: void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha); GLuint boundFrameBufferObject(); void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer); + void clearBufferf(GLint drawbuffer, const QVector4D &values); void clearColor(const QColor &color); void clearDepthValue(float depth); void clearStencilValue(int stencil); diff --git a/src/render/graphicshelpers/graphicshelperes2.cpp b/src/render/graphicshelpers/graphicshelperes2.cpp index 5a9714b12..02078c8d4 100644 --- a/src/render/graphicshelpers/graphicshelperes2.cpp +++ b/src/render/graphicshelpers/graphicshelperes2.cpp @@ -576,6 +576,13 @@ void GraphicsHelperES2::disablePrimitiveRestart() { } +void GraphicsHelperES2::clearBufferf(GLint drawbuffer, const QVector4D &values) +{ + Q_UNUSED(drawbuffer); + Q_UNUSED(values); + qWarning() << "glClearBuffer*() not supported by OpenGL ES 2.0"; +} + void GraphicsHelperES2::pointSize(bool programmable, GLfloat value) { // If this is not a reset to default values, print a warning diff --git a/src/render/graphicshelpers/graphicshelperes2_p.h b/src/render/graphicshelpers/graphicshelperes2_p.h index cf3e46a81..f65c3c61b 100644 --- a/src/render/graphicshelpers/graphicshelperes2_p.h +++ b/src/render/graphicshelpers/graphicshelperes2_p.h @@ -81,6 +81,7 @@ public: GLuint boundFrameBufferObject() Q_DECL_OVERRIDE; void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE; bool checkFrameBufferComplete() Q_DECL_OVERRIDE; + void clearBufferf(GLint drawbuffer, const QVector4D &values) Q_DECL_OVERRIDE; GLuint createFrameBufferObject() Q_DECL_OVERRIDE; void depthMask(GLenum mode) Q_DECL_OVERRIDE; void depthTest(GLenum mode) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl2.cpp b/src/render/graphicshelpers/graphicshelpergl2.cpp index a7d35a6ed..f97075f17 100644 --- a/src/render/graphicshelpers/graphicshelpergl2.cpp +++ b/src/render/graphicshelpers/graphicshelpergl2.cpp @@ -579,6 +579,13 @@ void GraphicsHelperGL2::disablePrimitiveRestart() { } +void GraphicsHelperGL2::clearBufferf(GLint drawbuffer, const QVector4D &values) +{ + Q_UNUSED(drawbuffer); + Q_UNUSED(values); + qWarning() << "glClearBuffer*() not supported by OpenGL 2.0"; +} + void GraphicsHelperGL2::pointSize(bool programmable, GLfloat value) { // Print a warning once for trying to set GL_PROGRAM_POINT_SIZE diff --git a/src/render/graphicshelpers/graphicshelpergl2_p.h b/src/render/graphicshelpers/graphicshelpergl2_p.h index 01f1399de..0d38b59c4 100644 --- a/src/render/graphicshelpers/graphicshelpergl2_p.h +++ b/src/render/graphicshelpers/graphicshelpergl2_p.h @@ -83,6 +83,7 @@ public: GLuint boundFrameBufferObject() Q_DECL_OVERRIDE; void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE; bool checkFrameBufferComplete() Q_DECL_OVERRIDE; + void clearBufferf(GLint drawbuffer, const QVector4D &values) Q_DECL_OVERRIDE; GLuint createFrameBufferObject() Q_DECL_OVERRIDE; void depthMask(GLenum mode) Q_DECL_OVERRIDE; void depthTest(GLenum mode) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl3.cpp b/src/render/graphicshelpers/graphicshelpergl3.cpp index ad8db389e..3c822c7e6 100644 --- a/src/render/graphicshelpers/graphicshelpergl3.cpp +++ b/src/render/graphicshelpers/graphicshelpergl3.cpp @@ -949,6 +949,12 @@ void GraphicsHelperGL3::disablePrimitiveRestart() m_funcs->glDisable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL3::clearBufferf(GLint drawbuffer, const QVector4D &values) +{ + GLfloat vec[4] = {values[0], values[1], values[2], values[3]}; + m_funcs->glClearBufferfv(GL_COLOR, drawbuffer, vec); +} + void GraphicsHelperGL3::pointSize(bool programmable, GLfloat value) { if (programmable) { diff --git a/src/render/graphicshelpers/graphicshelpergl3_3.cpp b/src/render/graphicshelpers/graphicshelpergl3_3.cpp index 5d45501cc..621444972 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_3.cpp +++ b/src/render/graphicshelpers/graphicshelpergl3_3.cpp @@ -946,6 +946,12 @@ void GraphicsHelperGL3_3::disablePrimitiveRestart() m_funcs->glDisable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL3_3::clearBufferf(GLint drawbuffer, const QVector4D &values) +{ + GLfloat vec[4] = {values[0], values[1], values[2], values[3]}; + m_funcs->glClearBufferfv(GL_COLOR, drawbuffer, vec); +} + void GraphicsHelperGL3_3::pointSize(bool programmable, GLfloat value) { if (programmable) { diff --git a/src/render/graphicshelpers/graphicshelpergl3_3_p.h b/src/render/graphicshelpers/graphicshelpergl3_3_p.h index f90e92d73..b395ccc6b 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_3_p.h +++ b/src/render/graphicshelpers/graphicshelpergl3_3_p.h @@ -84,6 +84,7 @@ public: GLuint boundFrameBufferObject() Q_DECL_OVERRIDE; void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE; bool checkFrameBufferComplete() Q_DECL_OVERRIDE; + void clearBufferf(GLint drawbuffer, const QVector4D &values) Q_DECL_OVERRIDE; GLuint createFrameBufferObject() Q_DECL_OVERRIDE; void depthMask(GLenum mode) Q_DECL_OVERRIDE; void depthTest(GLenum mode) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl3_p.h b/src/render/graphicshelpers/graphicshelpergl3_p.h index f67c22049..c6660aaa3 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_p.h +++ b/src/render/graphicshelpers/graphicshelpergl3_p.h @@ -84,6 +84,7 @@ public: GLuint boundFrameBufferObject() Q_DECL_OVERRIDE; void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE; bool checkFrameBufferComplete() Q_DECL_OVERRIDE; + void clearBufferf(GLint drawbuffer, const QVector4D &values) Q_DECL_OVERRIDE; GLuint createFrameBufferObject() Q_DECL_OVERRIDE; void depthMask(GLenum mode) Q_DECL_OVERRIDE; void depthTest(GLenum mode) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl4.cpp b/src/render/graphicshelpers/graphicshelpergl4.cpp index 7493db2e1..6dfd7f46e 100644 --- a/src/render/graphicshelpers/graphicshelpergl4.cpp +++ b/src/render/graphicshelpers/graphicshelpergl4.cpp @@ -937,6 +937,12 @@ void GraphicsHelperGL4::disablePrimitiveRestart() m_funcs->glDisable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL4::clearBufferf(GLint drawbuffer, const QVector4D &values) +{ + GLfloat vec[4] = {values[0], values[1], values[2], values[3]}; + m_funcs->glClearBufferfv(GL_COLOR, drawbuffer, vec); +} + void GraphicsHelperGL4::pointSize(bool programmable, GLfloat value) { if (programmable) { diff --git a/src/render/graphicshelpers/graphicshelpergl4_p.h b/src/render/graphicshelpers/graphicshelpergl4_p.h index e3404d838..c9cea669d 100644 --- a/src/render/graphicshelpers/graphicshelpergl4_p.h +++ b/src/render/graphicshelpers/graphicshelpergl4_p.h @@ -83,6 +83,7 @@ public: GLuint boundFrameBufferObject() Q_DECL_OVERRIDE; void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) Q_DECL_OVERRIDE; bool checkFrameBufferComplete() Q_DECL_OVERRIDE; + void clearBufferf(GLint drawbuffer, const QVector4D &values) Q_DECL_OVERRIDE; GLuint createFrameBufferObject() Q_DECL_OVERRIDE; void depthMask(GLenum mode) Q_DECL_OVERRIDE; void depthTest(GLenum mode) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelperinterface_p.h b/src/render/graphicshelpers/graphicshelperinterface_p.h index 84c70a417..458f92d61 100644 --- a/src/render/graphicshelpers/graphicshelperinterface_p.h +++ b/src/render/graphicshelpers/graphicshelperinterface_p.h @@ -94,6 +94,7 @@ public: virtual GLuint boundFrameBufferObject() = 0; virtual void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) = 0; virtual bool checkFrameBufferComplete() = 0; + virtual void clearBufferf(GLint drawbuffer, const QVector4D &values) = 0; virtual GLuint createFrameBufferObject() = 0; virtual void depthMask(GLenum mode) = 0; virtual void depthTest(GLenum mode) = 0; |