diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2014-02-05 19:49:13 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-07 18:48:14 +0100 |
commit | bbf3d01f78460b751334cd043b34940904e06eae (patch) | |
tree | 95ff77b3c9216916756abc25d1ff01e4b08415d1 /src/gui/opengl/qopengltexture.cpp | |
parent | 05f7f9bc58596000406bcbbd94123bb31b3cba33 (diff) |
QOpenGLTexture: fix support for 1D textures
OpenGL ES 2 doesn't support 1D textures. So introduce a proper
feature flag and warn if we try to allocate one there.
Change-Id: I73cf58c1f257d2472564f45bff222231e39aca52
Reviewed-by: James Turner <james.turner@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui/opengl/qopengltexture.cpp')
-rw-r--r-- | src/gui/opengl/qopengltexture.cpp | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 1d16c3ecaa..9a9f277b1b 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -319,15 +319,21 @@ void QOpenGLTexturePrivate::allocateMutableStorage() return; case QOpenGLTexture::Target1D: - for (int level = 0; level < mipLevels; ++level) - texFuncs->glTextureImage1D(textureId, target, bindingTarget, level, format, - mipLevelSize(level, dimensions[0]), - 0, - QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, 0); + if (features.testFlag(QOpenGLTexture::Texture1D)) { + for (int level = 0; level < mipLevels; ++level) + texFuncs->glTextureImage1D(textureId, target, bindingTarget, level, format, + mipLevelSize(level, dimensions[0]), + 0, + QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, 0); + } else { + qWarning("1D textures are not supported"); + return; + } break; case QOpenGLTexture::Target1DArray: - if (features.testFlag(QOpenGLTexture::TextureArrays)) { + if (features.testFlag(QOpenGLTexture::Texture1D) + && features.testFlag(QOpenGLTexture::TextureArrays)) { for (int level = 0; level < mipLevels; ++level) texFuncs->glTextureImage2D(textureId, target, bindingTarget, level, format, mipLevelSize(level, dimensions[0]), @@ -335,7 +341,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage() 0, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, 0); } else { - qWarning("Array textures are not supported"); + qWarning("1D array textures are not supported"); return; } break; @@ -433,16 +439,22 @@ void QOpenGLTexturePrivate::allocateImmutableStorage() return; case QOpenGLTexture::Target1D: - texFuncs->glTextureStorage1D(textureId, target, bindingTarget, mipLevels, format, - dimensions[0]); + if (features.testFlag(QOpenGLTexture::Texture1D)) { + texFuncs->glTextureStorage1D(textureId, target, bindingTarget, mipLevels, format, + dimensions[0]); + } else { + qWarning("1D textures are not supported"); + return; + } break; case QOpenGLTexture::Target1DArray: - if (features.testFlag(QOpenGLTexture::TextureArrays)) { + if (features.testFlag(QOpenGLTexture::Texture1D) + && features.testFlag(QOpenGLTexture::TextureArrays)) { texFuncs->glTextureStorage2D(textureId, target, bindingTarget, mipLevels, format, dimensions[0], layers); } else { - qWarning("Array textures are not supported"); + qWarning("1D array textures are not supported"); return; } break; @@ -1356,6 +1368,7 @@ QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target \value NPOTTextures Basic support for non-power-of-two textures \value NPOTTextureRepeat Full support for non-power-of-two textures including texture repeat modes + \value Texture1D Support for the 1 dimensional texture target */ /*! @@ -2427,6 +2440,10 @@ bool QOpenGLTexture::hasFeature(Feature feature) supported = ctx->hasExtension(QByteArrayLiteral("GL_ARB_texture_non_power_of_two")); break; + case Texture1D: + supported = f.version() >= qMakePair(1, 1); + break; + case MaxFeatureFlag: break; } |