diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-04-07 01:00:13 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-04-07 01:00:14 +0200 |
commit | 800119509837f4dfe3b4de1ecd88938ae6b18b71 (patch) | |
tree | a2d58870ac1d5a45c78e4da455d26b653758eee3 /src/gui/opengl/qopengltexture.cpp | |
parent | 093cf19f1efdfbba3edb76547917a51e5b8cdba5 (diff) | |
parent | 28c9ad199c313444149471e854bfa6cc7c708549 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Idf2bef470663864069bbf7e41af07b534936863a
Diffstat (limited to 'src/gui/opengl/qopengltexture.cpp')
-rw-r--r-- | src/gui/opengl/qopengltexture.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index b825b56d45..cea4b51a5c 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -2800,6 +2800,11 @@ QOpenGLTexture::TextureFormat QOpenGLTexture::format() const return d->format; } +static bool isNpot(int width, int height = 1, int depth = 1) +{ + return width & (width-1) || height & (height-1) || depth & (depth-1); +} + /*! Sets the dimensions of this texture object to \a width, \a height, and \a depth. The default for each dimension is 1. @@ -2807,6 +2812,10 @@ QOpenGLTexture::TextureFormat QOpenGLTexture::format() const implementation. Allocating storage for a texture less than the maximum size can still fail if your system is low on resources. + If a non-power-of-two \a width, \a height or \a depth is provided and your + OpenGL implementation doesn't have support for repeating non-power-of-two + textures, then the wrap mode is automatically set to ClampToEdge. + \sa width(), height(), depth() */ void QOpenGLTexture::setSize(int width, int height, int depth) @@ -2819,6 +2828,9 @@ void QOpenGLTexture::setSize(int width, int height, int depth) return; } + if (isNpot(width, height, depth) && !hasFeature(Feature::NPOTTextureRepeat) && d->target != Target::TargetRectangle) + d->setWrapMode(WrapMode::ClampToEdge); + switch (d->target) { case QOpenGLTexture::Target1D: case QOpenGLTexture::Target1DArray: |