diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-03-04 15:06:36 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-10 15:10:37 +0100 |
commit | 1e8de50674f5b33a50c45224b7e07b3f974f6ab0 (patch) | |
tree | a52d4e421be3c6c2deb4ff07905d5715012b0d9a /src/gui/opengl/qopengltexturecache.cpp | |
parent | 11eb9d37dc191b6e71c903e4f7f4d2da579e7df5 (diff) |
Avoid using direct OpenGL calls in gui and widgets
Change-Id: I5d88a2e204ca23e178a4e3044b9cb13392c3e763
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/gui/opengl/qopengltexturecache.cpp')
-rw-r--r-- | src/gui/opengl/qopengltexturecache.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp index 750264935b..f4aa29ac0f 100644 --- a/src/gui/opengl/qopengltexturecache.cpp +++ b/src/gui/opengl/qopengltexturecache.cpp @@ -117,7 +117,7 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, const QPixmap & if (!pixmap.paintingActive()) { QOpenGLCachedTexture *entry = m_cache.object(key); if (entry) { - glBindTexture(GL_TEXTURE_2D, entry->id()); + context->functions()->glBindTexture(GL_TEXTURE_2D, entry->id()); return entry->id(); } } @@ -154,7 +154,7 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, const QImage &i if (!image.paintingActive()) { QOpenGLCachedTexture *entry = m_cache.object(key); if (entry) { - glBindTexture(GL_TEXTURE_2D, entry->id()); + context->functions()->glBindTexture(GL_TEXTURE_2D, entry->id()); return entry->id(); } } @@ -181,12 +181,13 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, const QImage &i GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, const QImage &image) { GLuint id; - glGenTextures(1, &id); - glBindTexture(GL_TEXTURE_2D, id); + QOpenGLFunctions *funcs = context->functions(); + funcs->glGenTextures(1, &id); + funcs->glBindTexture(GL_TEXTURE_2D, id); QImage tx = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tx.width(), tx.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, const_cast<const QImage &>(tx).bits()); + funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tx.width(), tx.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, const_cast<const QImage &>(tx).bits()); int cost = tx.width() * tx.height() * 4 / 1024; m_cache.insert(key, new QOpenGLCachedTexture(id, context), cost); @@ -210,9 +211,9 @@ void QOpenGLTextureCache::freeResource(QOpenGLContext *) Q_ASSERT(false); // the texture cache lives until the context group disappears } -static void freeTexture(QOpenGLFunctions *, GLuint id) +static void freeTexture(QOpenGLFunctions *funcs, GLuint id) { - glDeleteTextures(1, &id); + funcs->glDeleteTextures(1, &id); } QOpenGLCachedTexture::QOpenGLCachedTexture(GLuint id, QOpenGLContext *context) |