summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2016-01-29 10:06:10 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-03-01 14:46:11 +0000
commit7ee585bbffb4350ec327116d30cd63e3d1142581 (patch)
treebf387974dce5d4b8d2b24ac4e953c94ff9d63f61 /src/gui
parent8611d442fc5d8020328889b023e0ab1c5d98ced6 (diff)
Don't resolve GL 1 symbols in the texture helper
We already have these symbols resolved in QOpenGLFunctions, so simply use those. Change-Id: I6047181dbe47be9b0a83656af454d0ca1f3df6eb Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/opengl/qopengltexture.cpp27
-rw-r--r--src/gui/opengl/qopengltexture_p.h2
-rw-r--r--src/gui/opengl/qopengltexturehelper.cpp142
-rw-r--r--src/gui/opengl/qopengltexturehelper_p.h140
4 files changed, 77 insertions, 234 deletions
diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp
index a0b482e1d2..23ae5febc0 100644
--- a/src/gui/opengl/qopengltexture.cpp
+++ b/src/gui/opengl/qopengltexture.cpp
@@ -81,7 +81,8 @@ QOpenGLTexturePrivate::QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarge
textureView(false),
autoGenerateMipMaps(true),
storageAllocated(false),
- texFuncs(0)
+ texFuncs(0),
+ functions(0)
{
dimensions[0] = dimensions[1] = dimensions[2] = 1;
@@ -165,6 +166,7 @@ bool QOpenGLTexturePrivate::create()
return false;
}
context = ctx;
+ functions = ctx->functions();
// Resolve any functions we will need based upon context version and create the texture
initializeOpenGLFunctions();
@@ -177,7 +179,7 @@ bool QOpenGLTexturePrivate::create()
feature = static_cast<QOpenGLTexture::Feature>(feature << 1);
}
- texFuncs->glGenTextures(1, &textureId);
+ functions->glGenTextures(1, &textureId);
return textureId != 0;
}
@@ -194,9 +196,10 @@ void QOpenGLTexturePrivate::destroy()
return;
}
- texFuncs->glDeleteTextures(1, &textureId);
+ functions->glDeleteTextures(1, &textureId);
context = 0;
+ functions = 0;
textureId = 0;
format = QOpenGLTexture::NoFormat;
formatClass = QOpenGLTexture::NoFormatClass;
@@ -231,17 +234,17 @@ void QOpenGLTexturePrivate::destroy()
void QOpenGLTexturePrivate::bind()
{
- texFuncs->glBindTexture(target, textureId);
+ functions->glBindTexture(target, textureId);
}
void QOpenGLTexturePrivate::bind(uint unit, QOpenGLTexture::TextureUnitReset reset)
{
GLint oldTextureUnit = 0;
if (reset == QOpenGLTexture::ResetTextureUnit)
- texFuncs->glGetIntegerv(GL_ACTIVE_TEXTURE, &oldTextureUnit);
+ functions->glGetIntegerv(GL_ACTIVE_TEXTURE, &oldTextureUnit);
texFuncs->glActiveTexture(GL_TEXTURE0 + unit);
- texFuncs->glBindTexture(target, textureId);
+ functions->glBindTexture(target, textureId);
if (reset == QOpenGLTexture::ResetTextureUnit)
texFuncs->glActiveTexture(GL_TEXTURE0 + oldTextureUnit);
@@ -249,17 +252,17 @@ void QOpenGLTexturePrivate::bind(uint unit, QOpenGLTexture::TextureUnitReset res
void QOpenGLTexturePrivate::release()
{
- texFuncs->glBindTexture(target, 0);
+ functions->glBindTexture(target, 0);
}
void QOpenGLTexturePrivate::release(uint unit, QOpenGLTexture::TextureUnitReset reset)
{
GLint oldTextureUnit = 0;
if (reset == QOpenGLTexture::ResetTextureUnit)
- texFuncs->glGetIntegerv(GL_ACTIVE_TEXTURE, &oldTextureUnit);
+ functions->glGetIntegerv(GL_ACTIVE_TEXTURE, &oldTextureUnit);
texFuncs->glActiveTexture(GL_TEXTURE0 + unit);
- texFuncs->glBindTexture(target, 0);
+ functions->glBindTexture(target, 0);
if (reset == QOpenGLTexture::ResetTextureUnit)
texFuncs->glActiveTexture(GL_TEXTURE0 + oldTextureUnit);
@@ -268,18 +271,18 @@ void QOpenGLTexturePrivate::release(uint unit, QOpenGLTexture::TextureUnitReset
bool QOpenGLTexturePrivate::isBound() const
{
GLint boundTextureId = 0;
- texFuncs->glGetIntegerv(bindingTarget, &boundTextureId);
+ functions->glGetIntegerv(bindingTarget, &boundTextureId);
return (static_cast<GLuint>(boundTextureId) == textureId);
}
bool QOpenGLTexturePrivate::isBound(uint unit) const
{
GLint oldTextureUnit = 0;
- texFuncs->glGetIntegerv(GL_ACTIVE_TEXTURE, &oldTextureUnit);
+ functions->glGetIntegerv(GL_ACTIVE_TEXTURE, &oldTextureUnit);
GLint boundTextureId = 0;
texFuncs->glActiveTexture(GL_TEXTURE0 + unit);
- texFuncs->glGetIntegerv(bindingTarget, &boundTextureId);
+ functions->glGetIntegerv(bindingTarget, &boundTextureId);
bool result = (static_cast<GLuint>(boundTextureId) == textureId);
texFuncs->glActiveTexture(GL_TEXTURE0 + oldTextureUnit);
diff --git a/src/gui/opengl/qopengltexture_p.h b/src/gui/opengl/qopengltexture_p.h
index 38c5f16536..e9ada026ed 100644
--- a/src/gui/opengl/qopengltexture_p.h
+++ b/src/gui/opengl/qopengltexture_p.h
@@ -70,6 +70,7 @@ QT_BEGIN_NAMESPACE
class QOpenGLContext;
class QOpenGLTextureHelper;
+class QOpenGLFunctions;
class QOpenGLTexturePrivate
{
@@ -163,6 +164,7 @@ public:
bool storageAllocated;
QOpenGLTextureHelper *texFuncs;
+ QOpenGLFunctions *functions;
QOpenGLTexture::Features features;
};
diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp
index a119183497..afac873795 100644
--- a/src/gui/opengl/qopengltexturehelper.cpp
+++ b/src/gui/opengl/qopengltexturehelper.cpp
@@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE
QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
{
+ functions = context->functions();
// Resolve EXT_direct_state_access entry points if present.
// However, disable it on some systems where DSA is known to be unreliable.
@@ -142,63 +143,26 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
TextureImage2DMultisample = &QOpenGLTextureHelper::qt_TextureImage2DMultisample;
}
+#if defined(Q_OS_WIN) && !defined(QT_OPENGL_ES_2)
// wglGetProcAddress should not be used to (and indeed will not) load OpenGL <= 1.1 functions.
// Hence, we resolve them "the hard way"
-
-#if defined(Q_OS_WIN) && !defined(QT_OPENGL_ES_2)
HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());
if (!handle)
handle = GetModuleHandleA("opengl32.dll");
- // OpenGL 1.0
- GetIntegerv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint *)>(GetProcAddress(handle, QByteArrayLiteral("glGetIntegerv")));
- GetBooleanv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLboolean *)>(GetProcAddress(handle, QByteArrayLiteral("glGetBooleanv")));
- PixelStorei = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint )>(GetProcAddress(handle, QByteArrayLiteral("glPixelStorei")));
- GetTexLevelParameteriv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLint *)>(GetProcAddress(handle, QByteArrayLiteral("glGetTexLevelParameteriv")));
- GetTexLevelParameterfv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLfloat *)>(GetProcAddress(handle, QByteArrayLiteral("glGetTexLevelParameterfv")));
- GetTexParameteriv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLint *)>(GetProcAddress(handle, QByteArrayLiteral("glGetTexParameteriv")));
- GetTexParameterfv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLfloat *)>(GetProcAddress(handle, QByteArrayLiteral("glGetTexParameterfv")));
- GetTexImage = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLenum , GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glGetTexImage")));
- TexImage2D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glTexImage2D")));
TexImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glTexImage1D")));
- TexParameteriv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , const GLint *)>(GetProcAddress(handle, QByteArrayLiteral("glTexParameteriv")));
- TexParameteri = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLint )>(GetProcAddress(handle, QByteArrayLiteral("glTexParameteri")));
- TexParameterfv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , const GLfloat *)>(GetProcAddress(handle, QByteArrayLiteral("glTexParameterfv")));
- TexParameterf = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLfloat )>(GetProcAddress(handle, QByteArrayLiteral("glTexParameterf")));
-
- // OpenGL 1.1
- GenTextures = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(GetProcAddress(handle, QByteArrayLiteral("glGenTextures")));
- DeleteTextures = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(GetProcAddress(handle, QByteArrayLiteral("glDeleteTextures")));
- BindTexture = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLuint )>(GetProcAddress(handle, QByteArrayLiteral("glBindTexture")));
- TexSubImage2D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glTexSubImage2D")));
TexSubImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glTexSubImage1D")));
+#endif
-#elif defined(QT_OPENGL_ES_2)
+#if defined(QT_OPENGL_ES_2)
// Here we are targeting OpenGL ES 2.0+ only. This is likely using EGL, where,
// similarly to WGL, non-extension functions (i.e. any function that is part of the
// GLES spec) *may* not be queried via eglGetProcAddress.
// OpenGL 1.0
- GetIntegerv = ::glGetIntegerv;
- GetBooleanv = ::glGetBooleanv;
- PixelStorei = ::glPixelStorei;
- GetTexLevelParameteriv = 0;
- GetTexLevelParameterfv = 0;
- GetTexParameteriv = ::glGetTexParameteriv;
- GetTexParameterfv = ::glGetTexParameterfv;
- GetTexImage = 0;
- TexImage2D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(::glTexImage2D);
TexImage1D = 0;
- TexParameteriv = ::glTexParameteriv;
- TexParameteri = ::glTexParameteri;
- TexParameterfv = ::glTexParameterfv;
- TexParameterf = ::glTexParameterf;
// OpenGL 1.1
- GenTextures = ::glGenTextures;
- DeleteTextures = ::glDeleteTextures;
- BindTexture = ::glBindTexture;
- TexSubImage2D = ::glTexSubImage2D;
TexSubImage1D = 0;
// OpenGL 1.3
@@ -235,30 +199,6 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
TexBufferRange = 0;
TextureView = 0;
-#else
-
- // OpenGL 1.0
- GetIntegerv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint *)>(context->getProcAddress(QByteArrayLiteral("glGetIntegerv")));
- GetBooleanv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLboolean *)>(context->getProcAddress(QByteArrayLiteral("glGetBooleanv")));
- PixelStorei = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint )>(context->getProcAddress(QByteArrayLiteral("glPixelStorei")));
- GetTexLevelParameteriv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLint *)>(context->getProcAddress(QByteArrayLiteral("glGetTexLevelParameteriv")));
- GetTexLevelParameterfv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLfloat *)>(context->getProcAddress(QByteArrayLiteral("glGetTexLevelParameterfv")));
- GetTexParameteriv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLint *)>(context->getProcAddress(QByteArrayLiteral("glGetTexParameteriv")));
- GetTexParameterfv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLfloat *)>(context->getProcAddress(QByteArrayLiteral("glGetTexParameterfv")));
- GetTexImage = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLenum , GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glGetTexImage")));
- TexImage2D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexImage2D")));
- TexImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexImage1D")));
- TexParameteriv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , const GLint *)>(context->getProcAddress(QByteArrayLiteral("glTexParameteriv")));
- TexParameteri = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLint )>(context->getProcAddress(QByteArrayLiteral("glTexParameteri")));
- TexParameterfv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , const GLfloat *)>(context->getProcAddress(QByteArrayLiteral("glTexParameterfv")));
- TexParameterf = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLfloat )>(context->getProcAddress(QByteArrayLiteral("glTexParameterf")));
-
- // OpenGL 1.1
- GenTextures = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(QByteArrayLiteral("glGenTextures")));
- DeleteTextures = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(QByteArrayLiteral("glDeleteTextures")));
- BindTexture = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLuint )>(context->getProcAddress(QByteArrayLiteral("glBindTexture")));
- TexSubImage2D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexSubImage2D")));
- TexSubImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexSubImage1D")));
#endif
if (context->isOpenGLES() && context->hasExtension(QByteArrayLiteral("GL_OES_texture_3D"))) {
@@ -464,8 +404,8 @@ namespace {
class TextureBinder
{
public:
- TextureBinder(QOpenGLTextureHelper *textureFunctions, GLuint texture, GLenum target, GLenum bindingTarget)
- : m_textureFunctions(textureFunctions)
+ TextureBinder(QOpenGLFunctions *functions, GLuint texture, GLenum target, GLenum bindingTarget)
+ : m_functions(functions)
{
// For cubemaps we can't use the standard DSA emulation as it is illegal to
// try to bind a texture to one of the cubemap face targets. So we force the
@@ -486,17 +426,17 @@ public:
break;
}
- m_textureFunctions->glGetIntegerv(bindingTarget, &m_oldTexture);
- m_textureFunctions->glBindTexture(m_target, texture);
+ m_functions->glGetIntegerv(bindingTarget, &m_oldTexture);
+ m_functions->glBindTexture(m_target, texture);
}
~TextureBinder()
{
- m_textureFunctions->glBindTexture(m_target, m_oldTexture);
+ m_functions->glBindTexture(m_target, m_oldTexture);
}
private:
- QOpenGLTextureHelper *m_textureFunctions;
+ QOpenGLFunctions *m_functions;
GLenum m_target;
GLint m_oldTexture;
};
@@ -505,145 +445,145 @@ private:
void QOpenGLTextureHelper::qt_TextureParameteri(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLint param)
{
- TextureBinder binder(this, texture, target, bindingTarget);
- glTexParameteri(target, pname, param);
+ TextureBinder binder(functions, texture, target, bindingTarget);
+ functions->glTexParameteri(target, pname, param);
}
void QOpenGLTextureHelper::qt_TextureParameteriv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLint *params)
{
- TextureBinder binder(this, texture, target, bindingTarget);
- glTexParameteriv(target, pname, params);
+ TextureBinder binder(functions, texture, target, bindingTarget);
+ functions->glTexParameteriv(target, pname, params);
}
void QOpenGLTextureHelper::qt_TextureParameterf(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLfloat param)
{
- TextureBinder binder(this, texture, target, bindingTarget);
- glTexParameterf(target, pname, param);
+ TextureBinder binder(functions, texture, target, bindingTarget);
+ functions->glTexParameterf(target, pname, param);
}
void QOpenGLTextureHelper::qt_TextureParameterfv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLfloat *params)
{
- TextureBinder binder(this, texture, target, bindingTarget);
- glTexParameterfv(target, pname, params);
+ TextureBinder binder(functions, texture, target, bindingTarget);
+ functions->glTexParameterfv(target, pname, params);
}
void QOpenGLTextureHelper::qt_GenerateTextureMipmap(GLuint texture, GLenum target, GLenum bindingTarget)
{
- TextureBinder binder(this, texture, target, bindingTarget);
- glGenerateMipmap(target);
+ TextureBinder binder(functions, texture, target, bindingTarget);
+ functions->glGenerateMipmap(target);
}
void QOpenGLTextureHelper::qt_TextureStorage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexStorage3D(target, levels, internalFormat, width, height, depth);
}
void QOpenGLTextureHelper::qt_TextureStorage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexStorage2D(target, levels, internalFormat, width, height);
}
void QOpenGLTextureHelper::qt_TextureStorage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexStorage1D(target, levels, internalFormat, width);
}
void QOpenGLTextureHelper::qt_TextureStorage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexStorage3DMultisample(target, samples, internalFormat, width, height, depth, fixedSampleLocations);
}
void QOpenGLTextureHelper::qt_TextureStorage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexStorage2DMultisample(target, samples, internalFormat, width, height, fixedSampleLocations);
}
void QOpenGLTextureHelper::qt_TextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, pixels);
}
void QOpenGLTextureHelper::qt_TextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
{
- TextureBinder binder(this, texture, target, bindingTarget);
- glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
+ TextureBinder binder(functions, texture, target, bindingTarget);
+ functions->glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
}
void QOpenGLTextureHelper::qt_TextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexImage1D(target, level, internalFormat, width, border, format, type, pixels);
}
void QOpenGLTextureHelper::qt_TextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
}
void QOpenGLTextureHelper::qt_TextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
{
- TextureBinder binder(this, texture, target, bindingTarget);
- glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
+ TextureBinder binder(functions, texture, target, bindingTarget);
+ functions->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
void QOpenGLTextureHelper::qt_TextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexSubImage1D(target, level, xoffset, width, format, type, pixels);
}
void QOpenGLTextureHelper::qt_TextureImage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexImage3DMultisample(target, samples, internalFormat, width, height, depth, fixedSampleLocations);
}
void QOpenGLTextureHelper::qt_TextureImage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glTexImage2DMultisample(target, samples, internalFormat, width, height, fixedSampleLocations);
}
void QOpenGLTextureHelper::qt_CompressedTextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glCompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, bits);
}
void QOpenGLTextureHelper::qt_CompressedTextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, bits);
}
void QOpenGLTextureHelper::qt_CompressedTextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, bits);
}
void QOpenGLTextureHelper::qt_CompressedTextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glCompressedTexImage1D(target, level, internalFormat, width, border, imageSize, bits);
}
void QOpenGLTextureHelper::qt_CompressedTextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glCompressedTexImage2D(target, level, internalFormat, width, height, border, imageSize, bits);
}
void QOpenGLTextureHelper::qt_CompressedTextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits)
{
- TextureBinder binder(this, texture, target, bindingTarget);
+ TextureBinder binder(functions, texture, target, bindingTarget);
glCompressedTexImage3D(target, level, internalFormat, width, height, depth, border, imageSize, bits);
}
diff --git a/src/gui/opengl/qopengltexturehelper_p.h b/src/gui/opengl/qopengltexturehelper_p.h
index bf655ed9db..a255672602 100644
--- a/src/gui/opengl/qopengltexturehelper_p.h
+++ b/src/gui/opengl/qopengltexturehelper_p.h
@@ -58,6 +58,7 @@
#include "qopengl.h"
#include "qopenglpixeltransferoptions.h"
#include "qopengltexture.h"
+#include "qopenglfunctions.h"
QT_BEGIN_NAMESPACE
@@ -472,54 +473,8 @@ private:
public:
// Raw OpenGL functions, resolved and used by our DSA-like static functions if no EXT_direct_state_access is available
- // OpenGL 1.0
- inline void glGetIntegerv(GLenum pname, GLint *params)
- {
- GetIntegerv(pname, params);
- }
-
- inline void glGetBooleanv(GLenum pname, GLboolean *params)
- {
- GetBooleanv(pname, params);
- }
-
- inline void glPixelStorei(GLenum pname, GLint param)
- {
- PixelStorei(pname, param);
- }
-
- inline void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
- {
- GetTexLevelParameteriv(target, level, pname, params);
- }
-
- inline void glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params)
- {
- GetTexLevelParameterfv(target, level, pname, params);
- }
-
- inline void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params)
- {
- GetTexParameteriv(target, pname, params);
- }
-
- inline void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
- {
- GetTexParameterfv(target, pname, params);
- }
-
- inline void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels)
- {
- GetTexImage(target, level, format, type, pixels);
- }
-
- inline void glTexImage2D(GLenum target, GLint level, GLint internalFormat,
- GLsizei width, GLsizei height, GLint border,
- GLenum format, GLenum type, const GLvoid *pixels)
- {
- TexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
- }
+ // OpenGL 1.0
inline void glTexImage1D(GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLint border,
GLenum format, GLenum type, const GLvoid *pixels)
@@ -527,48 +482,7 @@ public:
TexImage1D(target, level, internalFormat, width, border, format, type, pixels);
}
- inline void glTexParameteriv(GLenum target, GLenum pname, const GLint *params)
- {
- TexParameteriv(target, pname, params);
- }
-
- inline void glTexParameteri(GLenum target, GLenum pname, GLint param)
- {
- TexParameteri(target, pname, param);
- }
-
- inline void glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
- {
- TexParameterfv(target, pname, params);
- }
-
- inline void glTexParameterf(GLenum target, GLenum pname, GLfloat param)
- {
- TexParameterf(target, pname, param);
- }
-
// OpenGL 1.1
- inline void glGenTextures(GLsizei n, GLuint *textures)
- {
- GenTextures(n, textures);
- }
-
- inline void glDeleteTextures(GLsizei n, const GLuint *textures)
- {
- DeleteTextures(n, textures);
- }
-
- inline void glBindTexture(GLenum target, GLuint texture)
- {
- BindTexture(target, texture);
- }
-
- inline void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
- {
- TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
- }
-
inline void glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width,
GLenum format, GLenum type, const GLvoid *pixels)
{
@@ -704,23 +618,23 @@ public:
{
QOpenGLPixelTransferOptions options;
int val = 0;
- glGetIntegerv(GL_UNPACK_ALIGNMENT, &val);
+ functions->glGetIntegerv(GL_UNPACK_ALIGNMENT, &val);
options.setAlignment(val);
#if !defined(QT_OPENGL_ES_2)
- glGetIntegerv(GL_UNPACK_SKIP_IMAGES, &val);
+ functions->glGetIntegerv(GL_UNPACK_SKIP_IMAGES, &val);
options.setSkipImages(val);
- glGetIntegerv(GL_UNPACK_SKIP_ROWS, &val);
+ functions->glGetIntegerv(GL_UNPACK_SKIP_ROWS, &val);
options.setSkipRows(val);
- glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &val);
+ functions->glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &val);
options.setSkipPixels(val);
- glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &val);
+ functions->glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &val);
options.setImageHeight(val);
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, &val);
+ functions->glGetIntegerv(GL_UNPACK_ROW_LENGTH, &val);
options.setRowLength(val);
GLboolean b = GL_FALSE;
- glGetBooleanv(GL_UNPACK_LSB_FIRST, &b);
+ functions->glGetBooleanv(GL_UNPACK_LSB_FIRST, &b);
options.setLeastSignificantByteFirst(b);
- glGetBooleanv(GL_UNPACK_SWAP_BYTES, &b);
+ functions->glGetBooleanv(GL_UNPACK_SWAP_BYTES, &b);
options.setSwapBytesEnabled(b);
#endif
return options;
@@ -728,18 +642,19 @@ public:
inline void setPixelUploadOptions(const QOpenGLPixelTransferOptions &options)
{
- glPixelStorei(GL_UNPACK_ALIGNMENT, options.alignment());
+ functions->glPixelStorei(GL_UNPACK_ALIGNMENT, options.alignment());
#if !defined(QT_OPENGL_ES_2)
- glPixelStorei(GL_UNPACK_SKIP_IMAGES, options.skipImages());
- glPixelStorei(GL_UNPACK_SKIP_ROWS, options.skipRows());
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, options.skipPixels());
- glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, options.imageHeight());
- glPixelStorei(GL_UNPACK_ROW_LENGTH, options.rowLength());
- glPixelStorei(GL_UNPACK_LSB_FIRST, options.isLeastSignificantBitFirst());
- glPixelStorei(GL_UNPACK_SWAP_BYTES, options.isSwapBytesEnabled());
+ functions->glPixelStorei(GL_UNPACK_SKIP_IMAGES, options.skipImages());
+ functions->glPixelStorei(GL_UNPACK_SKIP_ROWS, options.skipRows());
+ functions->glPixelStorei(GL_UNPACK_SKIP_PIXELS, options.skipPixels());
+ functions->glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, options.imageHeight());
+ functions->glPixelStorei(GL_UNPACK_ROW_LENGTH, options.rowLength());
+ functions->glPixelStorei(GL_UNPACK_LSB_FIRST, options.isLeastSignificantBitFirst());
+ functions->glPixelStorei(GL_UNPACK_SWAP_BYTES, options.isSwapBytesEnabled());
#endif
}
+ QOpenGLFunctions *functions;
private:
// Typedefs and pointers to member functions used to switch between EXT_direct_state_access and our own emulated DSA.
// The argument match the corresponding GL function, but there's an extra "GLenum bindingTarget" which gets used with
@@ -827,26 +742,9 @@ private:
void (QOPENGLF_APIENTRYP TextureImage2DMultisampleNV)(GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
// OpenGL 1.0
- void (QOPENGLF_APIENTRYP GetIntegerv)(GLenum pname, GLint *params);
- void (QOPENGLF_APIENTRYP GetBooleanv)(GLenum pname, GLboolean *params);
- void (QOPENGLF_APIENTRYP PixelStorei)(GLenum pname, GLint param);
- void (QOPENGLF_APIENTRYP GetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint *params);
- void (QOPENGLF_APIENTRYP GetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat *params);
- void (QOPENGLF_APIENTRYP GetTexParameteriv)(GLenum target, GLenum pname, GLint *params);
- void (QOPENGLF_APIENTRYP GetTexParameterfv)(GLenum target, GLenum pname, GLfloat *params);
- void (QOPENGLF_APIENTRYP GetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
- void (QOPENGLF_APIENTRYP TexImage2D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void (QOPENGLF_APIENTRYP TexImage1D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
- void (QOPENGLF_APIENTRYP TexParameteriv)(GLenum target, GLenum pname, const GLint *params);
- void (QOPENGLF_APIENTRYP TexParameteri)(GLenum target, GLenum pname, GLint param);
- void (QOPENGLF_APIENTRYP TexParameterfv)(GLenum target, GLenum pname, const GLfloat *params);
- void (QOPENGLF_APIENTRYP TexParameterf)(GLenum target, GLenum pname, GLfloat param);
// OpenGL 1.1
- void (QOPENGLF_APIENTRYP GenTextures)(GLsizei n, GLuint *textures);
- void (QOPENGLF_APIENTRYP DeleteTextures)(GLsizei n, const GLuint *textures);
- void (QOPENGLF_APIENTRYP BindTexture)(GLenum target, GLuint texture);
- void (QOPENGLF_APIENTRYP TexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
void (QOPENGLF_APIENTRYP TexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
// OpenGL 1.2