diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-08-06 12:03:06 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-08-08 22:52:31 +0000 |
commit | 87666d391cb7d9cca520718bf86f5b514ae681cc (patch) | |
tree | 547845ad227587001a3e84f3150dddb9ff96956d /src/gui/opengl/qopengltexturehelper_p.h | |
parent | 9861d2bf1446dbbe0f59694db6c7eed44e5e4a13 (diff) |
Make compressed textures work with mutable storage
1. glTexImage*D does not accept compressed formats.
2. Replacing it with glCompressedTexImage*D is not an option as per GLES 2.0 spec
since passing null data is not allowed.
3. glCompressedTexSubImage*D must always be preceded by a glCompressedTexImage*d
(or glTexStorage*D) call.
4. Therefore the only way is to do nothing in allocateStorage() and switch to
glCompressedTexImage*D in setCompressedData() whenever mutable storage is in use.
This makes ETC1 textures working on the Beaglebone (and presumably others).
Change-Id: I21a040f6ed4aecaa494b6e5a6c6cd75b7389c15c
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui/opengl/qopengltexturehelper_p.h')
-rw-r--r-- | src/gui/opengl/qopengltexturehelper_p.h | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/gui/opengl/qopengltexturehelper_p.h b/src/gui/opengl/qopengltexturehelper_p.h index 5a56516b49..d659fcedfb 100644 --- a/src/gui/opengl/qopengltexturehelper_p.h +++ b/src/gui/opengl/qopengltexturehelper_p.h @@ -253,23 +253,48 @@ public: inline void glCompressedTextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, - GLint border, GLsizei imageSize, const GLvoid *bits) + GLint border, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = 0) { - (this->*CompressedTextureImage1D)(texture, target, bindingTarget, level, internalFormat, width, border, imageSize, bits); + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureImage1D)(texture, target, bindingTarget, level, internalFormat, width, border, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureImage1D)(texture, target, bindingTarget, level, internalFormat, width, border, imageSize, bits); + } } inline void glCompressedTextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, - GLint border, GLsizei imageSize, const GLvoid *bits) + GLint border, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = 0) + { - (this->*CompressedTextureImage2D)(texture, target, bindingTarget, level, internalFormat, width, height, border, imageSize, bits); + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureImage2D)(texture, target, bindingTarget, level, internalFormat, width, height, border, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureImage2D)(texture, target, bindingTarget, level, internalFormat, width, height, border, imageSize, bits); + } } inline void glCompressedTextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLsizei imageSize, const GLvoid *bits) + GLint border, GLsizei imageSize, const GLvoid *bits, + const QOpenGLPixelTransferOptions * const options = 0) { - (this->*CompressedTextureImage3D)(texture, target, bindingTarget, level, internalFormat, width, height, depth, border, imageSize, bits); + if (options) { + QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); + setPixelUploadOptions(*options); + (this->*CompressedTextureImage3D)(texture, target, bindingTarget, level, internalFormat, width, height, depth, border, imageSize, bits); + setPixelUploadOptions(oldOptions); + } else { + (this->*CompressedTextureImage3D)(texture, target, bindingTarget, level, internalFormat, width, height, depth, border, imageSize, bits); + } } private: |