summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-08-05 15:22:33 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-08-10 10:41:30 +0000
commit8103be87b5810f7dd30082844549a5192dd6d180 (patch)
treeb70a2238984791038c793734e5da6580929e2d2b
parente2e1a7986f92f76a2a2e79f911248de604af382f (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>
-rw-r--r--src/render/graphicshelpers/graphicshelperes2.cpp26
-rw-r--r--src/render/graphicshelpers/graphicshelperes2_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelperes3.cpp32
-rw-r--r--src/render/graphicshelpers/graphicshelperes3_p.h1
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2.cpp28
-rw-r--r--src/render/graphicshelpers/graphicshelpergl2_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_2.cpp37
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_2_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_3.cpp37
-rw-r--r--src/render/graphicshelpers/graphicshelpergl3_3_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelpergl4.cpp44
-rw-r--r--src/render/graphicshelpers/graphicshelpergl4_p.h2
-rw-r--r--src/render/graphicshelpers/graphicshelperinterface_p.h2
-rw-r--r--tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp74
-rw-r--r--tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp89
-rw-r--r--tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp89
-rw-r--r--tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp102
17 files changed, 566 insertions, 5 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;
diff --git a/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp b/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp
index 473e43d09..4a393c99f 100644
--- a/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp
+++ b/tests/auto/render/graphicshelpergl2/tst_graphicshelpergl2.cpp
@@ -33,8 +33,10 @@
#include <Qt3DRender/private/attachmentpack_p.h>
#include <QtOpenGLExtensions/QOpenGLExtensions>
#include <QOpenGLContext>
+#include <QOpenGLBuffer>
#include <QOpenGLFunctions_2_0>
#include <QOpenGLShaderProgram>
+#include <QOpenGLVertexArrayObject>
#include <QSurfaceFormat>
#ifndef QT_OPENGL_ES_2
@@ -592,6 +594,33 @@ private Q_SLOTS:
// Not supported by GL2
}
+ void enableVertexAttribute()
+ {
+ if (!m_initializationSuccessful)
+ QSKIP("Initialization failed, OpenGL 2.0 functions not supported");
+
+ // GIVEN
+ QOpenGLVertexArrayObject vao;
+ vao.create();
+ QOpenGLVertexArrayObject::Binder binder(&vao);
+
+ QOpenGLShaderProgram shaderProgram;
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertCode);
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragCodeSamplers);
+ QVERIFY(shaderProgram.link());
+ shaderProgram.bind();
+
+ // WHEN
+ GLint positionLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexPosition");
+ GLint texCoordLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoord");
+ m_glHelper.enableVertexAttributeArray(positionLocation);
+ m_glHelper.enableVertexAttributeArray(texCoordLocation);
+
+ // THEN
+ const GLint error = m_func->glGetError();
+ QVERIFY(error == 0);
+ }
+
void frontFace()
{
if (!m_initializationSuccessful)
@@ -993,6 +1022,51 @@ private Q_SLOTS:
// Not available in 3.2
}
+ void vertexAttributePointer()
+ {
+ if (!m_initializationSuccessful)
+ QSKIP("Initialization failed, OpenGL 4.3 Core functions not supported");
+
+ // GIVEN
+ QOpenGLVertexArrayObject vao;
+ vao.create();
+ QOpenGLVertexArrayObject::Binder binder(&vao);
+
+ QOpenGLShaderProgram shaderProgram;
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertCode);
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragCodeSamplers);
+ QVERIFY(shaderProgram.link());
+
+ GLint positionLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexPosition");
+ GLint texCoordLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoord");
+
+ const int vertexCount = 99;
+ QOpenGLBuffer positionBuffer(QOpenGLBuffer::VertexBuffer);
+ positionBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ positionBuffer.create();
+ positionBuffer.bind();
+ positionBuffer.allocate(vertexCount * sizeof(QVector3D));
+
+ QOpenGLBuffer texCoordBuffer(QOpenGLBuffer::VertexBuffer);
+ texCoordBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ texCoordBuffer.create();
+ texCoordBuffer.allocate(vertexCount * sizeof(QVector2D));
+
+ // WHEN
+ shaderProgram.bind();
+ positionBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(positionLocation);
+ m_glHelper.vertexAttributePointer(GL_FLOAT_VEC3, positionLocation, 3, GL_FLOAT, GL_TRUE, 0, 0);
+
+ texCoordBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(texCoordLocation);
+ m_glHelper.vertexAttributePointer(GL_FLOAT_VEC2, texCoordLocation, 2, GL_FLOAT, GL_TRUE, 0, 0);
+
+ // THEN
+ const GLint error = m_func->glGetError();
+ QVERIFY(error == 0);
+ }
+
void glUniform1fv()
{
if (!m_initializationSuccessful)
diff --git a/tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp b/tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp
index b66192835..38b566142 100644
--- a/tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp
+++ b/tests/auto/render/graphicshelpergl3_2/tst_graphicshelpergl3_2.cpp
@@ -31,8 +31,10 @@
#include <Qt3DRender/private/uniform_p.h>
#include <Qt3DRender/private/graphicshelpergl3_2_p.h>
#include <Qt3DRender/private/attachmentpack_p.h>
+#include <QOpenGLBuffer>
#include <QOpenGLFunctions_3_2_Core>
#include <QOpenGLShaderProgram>
+#include <QOpenGLVertexArrayObject>
#include <QSurfaceFormat>
#if !defined(QT_OPENGL_ES_2) && defined(QT_OPENGL_3_2)
@@ -139,6 +141,7 @@ const QByteArray fragCodeUniformsFloatMatrices = QByteArrayLiteral(
const QByteArray fragCodeUniformBuffer = QByteArrayLiteral(
"#version 150 core\n" \
"out vec4 color;\n" \
+ "in vec2 texCoord;\n" \
"flat in int colorIndex;\n" \
"uniform ColorArray\n" \
"{\n" \
@@ -146,7 +149,7 @@ const QByteArray fragCodeUniformBuffer = QByteArrayLiteral(
"};\n" \
"void main()\n" \
"{\n" \
- " color = colors[colorIndex];\n" \
+ " color = colors[colorIndex] + vec4(texCoord.s, texCoord.t, 0.0, 1.0);\n" \
"}\n");
const QByteArray fragCodeSamplers = QByteArrayLiteral(
@@ -803,6 +806,35 @@ private Q_SLOTS:
m_func->glDisable(GL_PRIMITIVE_RESTART);
}
+ void enableVertexAttribute()
+ {
+ if (!m_initializationSuccessful)
+ QSKIP("Initialization failed, OpenGL 3.2 Core functions not supported");
+
+ // GIVEN
+ QOpenGLVertexArrayObject vao;
+ vao.create();
+ QOpenGLVertexArrayObject::Binder binder(&vao);
+
+ QOpenGLShaderProgram shaderProgram;
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertCodeUniformBuffer);
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragCodeUniformBuffer);
+ QVERIFY(shaderProgram.link());
+ shaderProgram.bind();
+
+ // WHEN
+ GLint positionLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexPosition");
+ GLint texCoordLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoord");
+ GLint colorIndexLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexColorIndex");
+ m_glHelper.enableVertexAttributeArray(positionLocation);
+ m_glHelper.enableVertexAttributeArray(texCoordLocation);
+ m_glHelper.enableVertexAttributeArray(colorIndexLocation);
+
+ // THEN
+ const GLint error = m_func->glGetError();
+ QVERIFY(error == 0);
+ }
+
void frontFace()
{
if (!m_initializationSuccessful)
@@ -1298,6 +1330,61 @@ private Q_SLOTS:
// Not available in 3.2
}
+ void vertexAttributePointer()
+ {
+ if (!m_initializationSuccessful)
+ QSKIP("Initialization failed, OpenGL 4.3 Core functions not supported");
+
+ // GIVEN
+ QOpenGLVertexArrayObject vao;
+ vao.create();
+ QOpenGLVertexArrayObject::Binder binder(&vao);
+
+ QOpenGLShaderProgram shaderProgram;
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertCodeUniformBuffer);
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragCodeUniformBuffer);
+ QVERIFY(shaderProgram.link());
+
+ GLint positionLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexPosition");
+ GLint texCoordLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoord");
+ GLint colorIndexLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexColorIndex");
+
+ const int vertexCount = 99;
+ QOpenGLBuffer positionBuffer(QOpenGLBuffer::VertexBuffer);
+ positionBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ positionBuffer.create();
+ positionBuffer.bind();
+ positionBuffer.allocate(vertexCount * sizeof(QVector3D));
+
+ QOpenGLBuffer texCoordBuffer(QOpenGLBuffer::VertexBuffer);
+ texCoordBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ texCoordBuffer.create();
+ texCoordBuffer.allocate(vertexCount * sizeof(QVector2D));
+
+ QOpenGLBuffer colorIndexBuffer(QOpenGLBuffer::VertexBuffer);
+ colorIndexBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ colorIndexBuffer.create();
+ colorIndexBuffer.allocate(vertexCount * sizeof(int));
+
+ // WHEN
+ shaderProgram.bind();
+ positionBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(positionLocation);
+ m_glHelper.vertexAttributePointer(GL_FLOAT_VEC3, positionLocation, 3, GL_FLOAT, GL_TRUE, 0, 0);
+
+ texCoordBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(texCoordLocation);
+ m_glHelper.vertexAttributePointer(GL_FLOAT_VEC2, texCoordLocation, 2, GL_FLOAT, GL_TRUE, 0, 0);
+
+ colorIndexBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(colorIndexLocation);
+ m_glHelper.vertexAttributePointer(GL_INT, colorIndexLocation, 1, GL_INT, GL_TRUE, 0, 0);
+
+ // THEN
+ const GLint error = m_func->glGetError();
+ QVERIFY(error == 0);
+ }
+
void glUniform1fv()
{
if (!m_initializationSuccessful)
diff --git a/tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp b/tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp
index b7cc1cdac..b76287844 100644
--- a/tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp
+++ b/tests/auto/render/graphicshelpergl3_3/tst_graphicshelpergl3_3.cpp
@@ -31,8 +31,10 @@
#include <Qt3DRender/private/uniform_p.h>
#include <Qt3DRender/private/graphicshelpergl3_3_p.h>
#include <Qt3DRender/private/attachmentpack_p.h>
+#include <QOpenGLBuffer>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLShaderProgram>
+#include <QOpenGLVertexArrayObject>
#if !defined(QT_OPENGL_ES_2) && defined(QT_OPENGL_3_2)
@@ -138,6 +140,7 @@ const QByteArray fragCodeUniformsFloatMatrices = QByteArrayLiteral(
const QByteArray fragCodeUniformBuffer = QByteArrayLiteral(
"#version 330 core\n" \
"out vec4 color;\n" \
+ "in vec2 texCoord;\n" \
"flat in int colorIndex;\n" \
"uniform ColorArray\n" \
"{\n" \
@@ -145,7 +148,7 @@ const QByteArray fragCodeUniformBuffer = QByteArrayLiteral(
"};\n" \
"void main()\n" \
"{\n" \
- " color = colors[colorIndex];\n" \
+ " color = colors[colorIndex] + vec4(texCoord.s, texCoord.t, 0.0, 1.0);\n" \
"}\n");
const QByteArray fragCodeSamplers = QByteArrayLiteral(
@@ -902,6 +905,35 @@ private Q_SLOTS:
m_func->glDisable(GL_PRIMITIVE_RESTART);
}
+ void enableVertexAttribute()
+ {
+ if (!m_initializationSuccessful)
+ QSKIP("Initialization failed, OpenGL 3.3 Core functions not supported");
+
+ // GIVEN
+ QOpenGLVertexArrayObject vao;
+ vao.create();
+ QOpenGLVertexArrayObject::Binder binder(&vao);
+
+ QOpenGLShaderProgram shaderProgram;
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertCodeUniformBuffer);
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragCodeUniformBuffer);
+ QVERIFY(shaderProgram.link());
+ shaderProgram.bind();
+
+ // WHEN
+ GLint positionLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexPosition");
+ GLint texCoordLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoord");
+ GLint colorIndexLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexColorIndex");
+ m_glHelper.enableVertexAttributeArray(positionLocation);
+ m_glHelper.enableVertexAttributeArray(texCoordLocation);
+ m_glHelper.enableVertexAttributeArray(colorIndexLocation);
+
+ // THEN
+ const GLint error = m_func->glGetError();
+ QVERIFY(error == 0);
+ }
+
void frontFace()
{
if (!m_initializationSuccessful)
@@ -1397,6 +1429,61 @@ private Q_SLOTS:
QSKIP("Initialization failed, OpenGL 3.3 Core functions not supported");
}
+ void vertexAttributePointer()
+ {
+ if (!m_initializationSuccessful)
+ QSKIP("Initialization failed, OpenGL 4.3 Core functions not supported");
+
+ // GIVEN
+ QOpenGLVertexArrayObject vao;
+ vao.create();
+ QOpenGLVertexArrayObject::Binder binder(&vao);
+
+ QOpenGLShaderProgram shaderProgram;
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertCodeUniformBuffer);
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragCodeUniformBuffer);
+ QVERIFY(shaderProgram.link());
+
+ GLint positionLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexPosition");
+ GLint texCoordLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoord");
+ GLint colorIndexLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexColorIndex");
+
+ const int vertexCount = 99;
+ QOpenGLBuffer positionBuffer(QOpenGLBuffer::VertexBuffer);
+ positionBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ positionBuffer.create();
+ positionBuffer.bind();
+ positionBuffer.allocate(vertexCount * sizeof(QVector3D));
+
+ QOpenGLBuffer texCoordBuffer(QOpenGLBuffer::VertexBuffer);
+ texCoordBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ texCoordBuffer.create();
+ texCoordBuffer.allocate(vertexCount * sizeof(QVector2D));
+
+ QOpenGLBuffer colorIndexBuffer(QOpenGLBuffer::VertexBuffer);
+ colorIndexBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ colorIndexBuffer.create();
+ colorIndexBuffer.allocate(vertexCount * sizeof(int));
+
+ // WHEN
+ shaderProgram.bind();
+ positionBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(positionLocation);
+ m_glHelper.vertexAttributePointer(GL_FLOAT_VEC3, positionLocation, 3, GL_FLOAT, GL_TRUE, 0, 0);
+
+ texCoordBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(texCoordLocation);
+ m_glHelper.vertexAttributePointer(GL_FLOAT_VEC2, texCoordLocation, 2, GL_FLOAT, GL_TRUE, 0, 0);
+
+ colorIndexBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(colorIndexLocation);
+ m_glHelper.vertexAttributePointer(GL_INT, colorIndexLocation, 1, GL_INT, GL_TRUE, 0, 0);
+
+ // THEN
+ const GLint error = m_func->glGetError();
+ QVERIFY(error == 0);
+ }
+
void glUniform1fv()
{
if (!m_initializationSuccessful)
diff --git a/tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp b/tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp
index 0ee14841c..91fe3d3d4 100644
--- a/tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp
+++ b/tests/auto/render/graphicshelpergl4/tst_graphicshelpergl4.cpp
@@ -31,8 +31,10 @@
#include <Qt3DRender/private/uniform_p.h>
#include <Qt3DRender/private/graphicshelpergl4_p.h>
#include <Qt3DRender/private/attachmentpack_p.h>
+#include <QOpenGLBuffer>
#include <QOpenGLFunctions_4_3_Core>
#include <QOpenGLShaderProgram>
+#include <QOpenGLVertexArrayObject>
#include <QSurfaceFormat>
#if !defined(QT_OPENGL_ES_2) && defined(QT_OPENGL_4_3)
@@ -60,11 +62,12 @@ const QByteArray vertCodeUniformBuffer = QByteArrayLiteral(
"layout(location = 1) in vec3 vertexPosition;\n" \
"layout(location = 2) in vec2 vertexTexCoord;\n" \
"layout(location = 3) in int vertexColorIndex;\n" \
+ "layout(location = 4) in double vertexTexCoordScale;\n" \
"out vec2 texCoord;\n" \
"flat out int colorIndex;\n" \
"void main()\n" \
"{\n" \
- " texCoord = vertexTexCoord;\n" \
+ " texCoord = vec2(vertexTexCoordScale * vertexTexCoord);\n" \
" colorIndex = vertexColorIndex;\n" \
" gl_Position = vec4(vertexPosition, 1.0);\n" \
"}\n");
@@ -139,6 +142,7 @@ const QByteArray fragCodeUniformsFloatMatrices = QByteArrayLiteral(
const QByteArray fragCodeUniformBuffer = QByteArrayLiteral(
"#version 430 core\n" \
"out vec4 color;\n" \
+ "in vec2 texCoord;\n" \
"flat in int colorIndex;\n" \
"layout(binding = 2, std140) uniform ColorArray\n" \
"{\n" \
@@ -146,7 +150,7 @@ const QByteArray fragCodeUniformBuffer = QByteArrayLiteral(
"};\n" \
"void main()\n" \
"{\n" \
- " color = colors[colorIndex];\n" \
+ " color = colors[colorIndex] + vec4(texCoord.s, texCoord.t, 0.0, 1.0);\n" \
"}\n");
const QByteArray fragCodeSamplers = QByteArrayLiteral(
@@ -1000,6 +1004,35 @@ private Q_SLOTS:
m_func->glDisable(GL_PRIMITIVE_RESTART);
}
+ void enableVertexAttribute()
+ {
+ if (!m_initializationSuccessful)
+ QSKIP("Initialization failed, OpenGL 4.3 Core functions not supported");
+
+ // GIVEN
+ QOpenGLVertexArrayObject vao;
+ vao.create();
+ QOpenGLVertexArrayObject::Binder binder(&vao);
+
+ QOpenGLShaderProgram shaderProgram;
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertCodeUniformBuffer);
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragCodeUniformBuffer);
+ QVERIFY(shaderProgram.link());
+ shaderProgram.bind();
+
+ // WHEN
+ GLint positionLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexPosition");
+ GLint texCoordLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoord");
+ GLint colorIndexLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexColorIndex");
+ m_glHelper.enableVertexAttributeArray(positionLocation);
+ m_glHelper.enableVertexAttributeArray(texCoordLocation);
+ m_glHelper.enableVertexAttributeArray(colorIndexLocation);
+
+ // THEN
+ const GLint error = m_func->glGetError();
+ QVERIFY(error == 0);
+ }
+
void frontFace()
{
if (!m_initializationSuccessful)
@@ -1487,6 +1520,71 @@ private Q_SLOTS:
QSKIP("Initialization failed, OpenGL 4.3 Core functions not supported");
}
+ void vertexAttributePointer()
+ {
+ if (!m_initializationSuccessful)
+ QSKIP("Initialization failed, OpenGL 4.3 Core functions not supported");
+
+ // GIVEN
+ QOpenGLVertexArrayObject vao;
+ vao.create();
+ QOpenGLVertexArrayObject::Binder binder(&vao);
+
+ QOpenGLShaderProgram shaderProgram;
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertCodeUniformBuffer);
+ shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragCodeUniformBuffer);
+ QVERIFY(shaderProgram.link());
+
+ GLint positionLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexPosition");
+ GLint texCoordLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoord");
+ GLint colorIndexLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexColorIndex");
+ GLint texCoordScaleLocation = m_func->glGetAttribLocation(shaderProgram.programId(), "vertexTexCoordScale");
+
+ const int vertexCount = 99;
+ QOpenGLBuffer positionBuffer(QOpenGLBuffer::VertexBuffer);
+ positionBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ positionBuffer.create();
+ positionBuffer.bind();
+ positionBuffer.allocate(vertexCount * sizeof(QVector3D));
+
+ QOpenGLBuffer texCoordBuffer(QOpenGLBuffer::VertexBuffer);
+ texCoordBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ texCoordBuffer.create();
+ texCoordBuffer.allocate(vertexCount * sizeof(QVector2D));
+
+ QOpenGLBuffer colorIndexBuffer(QOpenGLBuffer::VertexBuffer);
+ colorIndexBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ colorIndexBuffer.create();
+ colorIndexBuffer.allocate(vertexCount * sizeof(int));
+
+ QOpenGLBuffer scaleBuffer(QOpenGLBuffer::VertexBuffer);
+ scaleBuffer.setUsagePattern(QOpenGLBuffer::StaticDraw);
+ scaleBuffer.create();
+ scaleBuffer.allocate(vertexCount * sizeof(double));
+
+ // WHEN
+ shaderProgram.bind();
+ positionBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(positionLocation);
+ m_glHelper.vertexAttributePointer(GL_FLOAT_VEC3, positionLocation, 3, GL_FLOAT, GL_TRUE, 0, 0);
+
+ texCoordBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(texCoordLocation);
+ m_glHelper.vertexAttributePointer(GL_FLOAT_VEC2, texCoordLocation, 2, GL_FLOAT, GL_TRUE, 0, 0);
+
+ colorIndexBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(colorIndexLocation);
+ m_glHelper.vertexAttributePointer(GL_INT, colorIndexLocation, 1, GL_INT, GL_TRUE, 0, 0);
+
+ scaleBuffer.bind();
+ m_glHelper.enableVertexAttributeArray(colorIndexLocation);
+ m_glHelper.vertexAttributePointer(GL_DOUBLE, texCoordScaleLocation, 1, GL_DOUBLE, GL_TRUE, 0, 0);
+
+ // THEN
+ const GLint error = m_func->glGetError();
+ QVERIFY(error == 0);
+ }
+
void glUniform1fv()
{
if (!m_initializationSuccessful)