diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-08-05 15:22:33 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-08-10 10:41:30 +0000 |
commit | 8103be87b5810f7dd30082844549a5192dd6d180 (patch) | |
tree | b70a2238984791038c793734e5da6580929e2d2b /src/render/graphicshelpers | |
parent | e2e1a7986f92f76a2a2e79f911248de604af382f (diff) |
Add wrappers for glEnableVertexAttrib and glVertexAttrib*Pointer
Needed to work around QTBUG-43199 to be able to specify integer
vertex attributes such as joint indices.
Change-Id: I39ab83e881b6afb75467c76b56125917013b3bca
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/graphicshelpers')
-rw-r--r-- | src/render/graphicshelpers/graphicshelperes2.cpp | 26 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelperes2_p.h | 2 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelperes3.cpp | 32 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelperes3_p.h | 1 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelpergl2.cpp | 28 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelpergl2_p.h | 2 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelpergl3_2.cpp | 37 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelpergl3_2_p.h | 2 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelpergl3_3.cpp | 37 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelpergl3_3_p.h | 2 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelpergl4.cpp | 44 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelpergl4_p.h | 2 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicshelperinterface_p.h | 2 |
13 files changed, 216 insertions, 1 deletions
diff --git a/src/render/graphicshelpers/graphicshelperes2.cpp b/src/render/graphicshelpers/graphicshelperes2.cpp index 200b749ee..0c4239dc9 100644 --- a/src/render/graphicshelpers/graphicshelperes2.cpp +++ b/src/render/graphicshelpers/graphicshelperes2.cpp @@ -249,6 +249,27 @@ void GraphicsHelperES2::vertexAttribDivisor(GLuint index, GLuint divisor) Q_UNUSED(divisor); } +void GraphicsHelperES2::vertexAttributePointer(GLenum shaderDataType, + GLuint index, + GLint size, + GLenum type, + GLboolean normalized, + GLsizei stride, + const GLvoid *pointer) +{ + switch (shaderDataType) { + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer); + break; + + default: + qCWarning(Render::Rendering) << "vertexAttribPointer: Unhandled type"; + } +} + void GraphicsHelperES2::blendEquation(GLenum mode) { m_funcs->glBlendEquation(mode); @@ -530,6 +551,11 @@ void GraphicsHelperES2::enablePrimitiveRestart(int) { } +void GraphicsHelperES2::enableVertexAttributeArray(int location) +{ + m_funcs->glEnableVertexAttribArray(location); +} + void GraphicsHelperES2::disablePrimitiveRestart() { } diff --git a/src/render/graphicshelpers/graphicshelperes2_p.h b/src/render/graphicshelpers/graphicshelperes2_p.h index 28d58b368..d068b5307 100644 --- a/src/render/graphicshelpers/graphicshelperes2_p.h +++ b/src/render/graphicshelpers/graphicshelperes2_p.h @@ -106,6 +106,7 @@ public: void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; + void enableVertexAttributeArray(int location) Q_DECL_OVERRIDE; void frontFace(GLenum mode) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; @@ -127,6 +128,7 @@ public: uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE; void useProgram(GLuint programId) Q_DECL_OVERRIDE; void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE; + void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) Q_DECL_OVERRIDE; void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelperes3.cpp b/src/render/graphicshelpers/graphicshelperes3.cpp index 4c5ae4ec6..d970bcd74 100644 --- a/src/render/graphicshelpers/graphicshelperes3.cpp +++ b/src/render/graphicshelpers/graphicshelperes3.cpp @@ -184,6 +184,38 @@ void GraphicsHelperES3::vertexAttribDivisor(GLuint index, GLuint divisor) m_extraFuncs->glVertexAttribDivisor(index, divisor); } +void GraphicsHelperES3::vertexAttributePointer(GLenum shaderDataType, + GLuint index, + GLint size, + GLenum type, + GLboolean normalized, + GLsizei stride, + const GLvoid *pointer) +{ + switch (shaderDataType) { + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer); + break; + + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + m_extraFuncs->glVertexAttribIPointer(index, size, type, stride, pointer); + break; + + default: + qCWarning(Render::Rendering) << "vertexAttribPointer: Unhandled type"; + } +} + void GraphicsHelperES3::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) { GLenum attr = GL_COLOR_ATTACHMENT0; diff --git a/src/render/graphicshelpers/graphicshelperes3_p.h b/src/render/graphicshelpers/graphicshelperes3_p.h index 0b12a0509..7a460895f 100644 --- a/src/render/graphicshelpers/graphicshelperes3_p.h +++ b/src/render/graphicshelpers/graphicshelperes3_p.h @@ -80,6 +80,7 @@ public: bool supportsFeature(Feature feature) const Q_DECL_OVERRIDE; GLboolean unmapBuffer(GLenum target) Q_DECL_OVERRIDE; void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE; + void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) Q_DECL_OVERRIDE; UniformType uniformTypeFromGLType(GLenum glType) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl2.cpp b/src/render/graphicshelpers/graphicshelpergl2.cpp index 6893760b1..ff16abc76 100644 --- a/src/render/graphicshelpers/graphicshelpergl2.cpp +++ b/src/render/graphicshelpers/graphicshelpergl2.cpp @@ -43,7 +43,7 @@ #include <private/attachmentpack_p.h> #include <QtOpenGLExtensions/QOpenGLExtensions> #include <private/qgraphicsutils_p.h> -#include <QDebug> +#include <Qt3DRender/private/renderlogging_p.h> QT_BEGIN_NAMESPACE @@ -227,6 +227,27 @@ void GraphicsHelperGL2::vertexAttribDivisor(GLuint index, Q_UNUSED(divisor); } +void GraphicsHelperGL2::vertexAttributePointer(GLenum shaderDataType, + GLuint index, + GLint size, + GLenum type, + GLboolean normalized, + GLsizei stride, + const GLvoid *pointer) +{ + switch (shaderDataType) { + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer); + break; + + default: + qCWarning(Render::Rendering) << "vertexAttribPointer: Unhandled type"; + } +} + void GraphicsHelperGL2::blendEquation(GLenum mode) { m_funcs->glBlendEquation(mode); @@ -541,6 +562,11 @@ void GraphicsHelperGL2::enablePrimitiveRestart(int) { } +void GraphicsHelperGL2::enableVertexAttributeArray(int location) +{ + m_funcs->glEnableVertexAttribArray(location); +} + void GraphicsHelperGL2::disablePrimitiveRestart() { } diff --git a/src/render/graphicshelpers/graphicshelpergl2_p.h b/src/render/graphicshelpers/graphicshelpergl2_p.h index a7450430e..7d617937d 100644 --- a/src/render/graphicshelpers/graphicshelpergl2_p.h +++ b/src/render/graphicshelpers/graphicshelpergl2_p.h @@ -106,6 +106,7 @@ public: void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; + void enableVertexAttributeArray(int location) Q_DECL_OVERRIDE; void frontFace(GLenum mode) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; @@ -127,6 +128,7 @@ public: uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE; void useProgram(GLuint programId) Q_DECL_OVERRIDE; void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE; + void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) Q_DECL_OVERRIDE; void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl3_2.cpp b/src/render/graphicshelpers/graphicshelpergl3_2.cpp index bb3547dd7..e879e1ce6 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_2.cpp +++ b/src/render/graphicshelpers/graphicshelpergl3_2.cpp @@ -279,6 +279,38 @@ void GraphicsHelperGL3_2::vertexAttribDivisor(GLuint index, GLuint divisor) qCWarning(Render::Rendering) << "Vertex attribute divisor not available with OpenGL 3.2 core"; } +void GraphicsHelperGL3_2::vertexAttributePointer(GLenum shaderDataType, + GLuint index, + GLint size, + GLenum type, + GLboolean normalized, + GLsizei stride, + const GLvoid *pointer) +{ + switch (shaderDataType) { + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer); + break; + + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + m_funcs->glVertexAttribIPointer(index, size, type, stride, pointer); + break; + + default: + qCWarning(Render::Rendering) << "vertexAttribPointer: Unhandled type"; + } +} + void GraphicsHelperGL3_2::blendEquation(GLenum mode) { m_funcs->glBlendEquation(mode); @@ -822,6 +854,11 @@ void GraphicsHelperGL3_2::enablePrimitiveRestart(int primitiveRestartIndex) m_funcs->glEnable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL3_2::enableVertexAttributeArray(int location) +{ + m_funcs->glEnableVertexAttribArray(location); +} + void GraphicsHelperGL3_2::disablePrimitiveRestart() { m_funcs->glDisable(GL_PRIMITIVE_RESTART); diff --git a/src/render/graphicshelpers/graphicshelpergl3_2_p.h b/src/render/graphicshelpers/graphicshelpergl3_2_p.h index 5595d1bc3..94ff4b4eb 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_2_p.h +++ b/src/render/graphicshelpers/graphicshelpergl3_2_p.h @@ -108,6 +108,7 @@ public: void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; + void enableVertexAttributeArray(int location) Q_DECL_OVERRIDE; void frontFace(GLenum mode) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; @@ -129,6 +130,7 @@ public: uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE; void useProgram(GLuint programId) Q_DECL_OVERRIDE; void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE; + void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) Q_DECL_OVERRIDE; void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl3_3.cpp b/src/render/graphicshelpers/graphicshelpergl3_3.cpp index abde62355..fbb1455c6 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_3.cpp +++ b/src/render/graphicshelpers/graphicshelpergl3_3.cpp @@ -276,6 +276,38 @@ void GraphicsHelperGL3_3::vertexAttribDivisor(GLuint index, GLuint divisor) m_funcs->glVertexAttribDivisor(index, divisor); } +void GraphicsHelperGL3_3::vertexAttributePointer(GLenum shaderDataType, + GLuint index, + GLint size, + GLenum type, + GLboolean normalized, + GLsizei stride, + const GLvoid *pointer) +{ + switch (shaderDataType) { + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer); + break; + + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + m_funcs->glVertexAttribIPointer(index, size, type, stride, pointer); + break; + + default: + qCWarning(Render::Rendering) << "vertexAttribPointer: Unhandled type"; + } +} + void GraphicsHelperGL3_3::blendEquation(GLenum mode) { m_funcs->glBlendEquation(mode); @@ -819,6 +851,11 @@ void GraphicsHelperGL3_3::enablePrimitiveRestart(int primitiveRestartIndex) m_funcs->glEnable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL3_3::enableVertexAttributeArray(int location) +{ + m_funcs->glEnableVertexAttribArray(location); +} + void GraphicsHelperGL3_3::disablePrimitiveRestart() { m_funcs->glDisable(GL_PRIMITIVE_RESTART); diff --git a/src/render/graphicshelpers/graphicshelpergl3_3_p.h b/src/render/graphicshelpers/graphicshelpergl3_3_p.h index 12ef374d3..3b03cf851 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_3_p.h +++ b/src/render/graphicshelpers/graphicshelpergl3_3_p.h @@ -108,6 +108,7 @@ public: void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; + void enableVertexAttributeArray(int location) Q_DECL_OVERRIDE; void frontFace(GLenum mode) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; @@ -129,6 +130,7 @@ public: uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE; void useProgram(GLuint programId) Q_DECL_OVERRIDE; void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE; + void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) Q_DECL_OVERRIDE; void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl4.cpp b/src/render/graphicshelpers/graphicshelpergl4.cpp index f428b667c..434ffd783 100644 --- a/src/render/graphicshelpers/graphicshelpergl4.cpp +++ b/src/render/graphicshelpers/graphicshelpergl4.cpp @@ -338,6 +338,45 @@ void GraphicsHelperGL4::vertexAttribDivisor(GLuint index, GLuint divisor) m_funcs->glVertexAttribDivisor(index, divisor); } +void GraphicsHelperGL4::vertexAttributePointer(GLenum shaderDataType, + GLuint index, + GLint size, + GLenum type, + GLboolean normalized, + GLsizei stride, + const GLvoid *pointer) +{ + switch (shaderDataType) { + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer); + break; + + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + m_funcs->glVertexAttribIPointer(index, size, type, stride, pointer); + break; + + case GL_DOUBLE: + case GL_DOUBLE_VEC2: + case GL_DOUBLE_VEC3: + case GL_DOUBLE_VEC4: + m_funcs->glVertexAttribLPointer(index, size, type, stride, pointer); + break; + + default: + qCWarning(Render::Rendering) << "vertexAttribPointer: Unhandled type"; + } +} + void GraphicsHelperGL4::glUniform1fv(GLint location, GLsizei count, const GLfloat *values) { m_funcs->glUniform1fv(location, count, values); @@ -1071,6 +1110,11 @@ void GraphicsHelperGL4::enablePrimitiveRestart(int primitiveRestartIndex) m_funcs->glEnable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL4::enableVertexAttributeArray(int location) +{ + m_funcs->glEnableVertexAttribArray(location); +} + void GraphicsHelperGL4::disablePrimitiveRestart() { m_funcs->glDisable(GL_PRIMITIVE_RESTART); diff --git a/src/render/graphicshelpers/graphicshelpergl4_p.h b/src/render/graphicshelpers/graphicshelpergl4_p.h index 8bb759b3b..e636832b3 100644 --- a/src/render/graphicshelpers/graphicshelpergl4_p.h +++ b/src/render/graphicshelpers/graphicshelpergl4_p.h @@ -106,6 +106,7 @@ public: void enableClipPlane(int clipPlane) Q_DECL_OVERRIDE; void enablei(GLenum cap, GLuint index) Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; + void enableVertexAttributeArray(int location) Q_DECL_OVERRIDE; void frontFace(GLenum mode) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; @@ -127,6 +128,7 @@ public: uint uniformByteSize(const ShaderUniform &description) Q_DECL_OVERRIDE; void useProgram(GLuint programId) Q_DECL_OVERRIDE; void vertexAttribDivisor(GLuint index, GLuint divisor) Q_DECL_OVERRIDE; + void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) Q_DECL_OVERRIDE; void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelperinterface_p.h b/src/render/graphicshelpers/graphicshelperinterface_p.h index 49bec44f1..45326eb91 100644 --- a/src/render/graphicshelpers/graphicshelperinterface_p.h +++ b/src/render/graphicshelpers/graphicshelperinterface_p.h @@ -123,6 +123,7 @@ public: virtual void enableClipPlane(int clipPlane) = 0; virtual void enablei(GLenum cap, GLuint index) = 0; virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0; + virtual void enableVertexAttributeArray(int location) = 0; virtual void frontFace(GLenum mode) = 0; virtual QSize getRenderBufferDimensions(GLuint renderBufferId) = 0; virtual QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) = 0; @@ -144,6 +145,7 @@ public: virtual uint uniformByteSize(const ShaderUniform &description) = 0; virtual void useProgram(GLuint programId) = 0; virtual void vertexAttribDivisor(GLuint index, GLuint divisor) = 0; + virtual void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) = 0; virtual void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) = 0; virtual void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) = 0; |