aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-05-11 17:46:06 +0200
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-05-12 10:13:00 +0200
commit35559a2f00fc9bf609144a6bba3f0a678f61cd12 (patch)
tree52f2a0b49ff3436990fc088cd974f75fff9ae72f /src
parent108f7cec20c105c07a34cded24fc1632b86e15c2 (diff)
Output warning if using unsupported texture wrap mode.
The REPEAT wrap mode is not supported by default for non- power-of-two textures in OpenGL ES 2. Output warning in QSGTexture::updateBindOptions() in debug mode.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/scenegraph/util/qsgtexture.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/declarative/scenegraph/util/qsgtexture.cpp b/src/declarative/scenegraph/util/qsgtexture.cpp
index 9362ba8bf6..c82f214cc8 100644
--- a/src/declarative/scenegraph/util/qsgtexture.cpp
+++ b/src/declarative/scenegraph/util/qsgtexture.cpp
@@ -48,6 +48,12 @@
QT_BEGIN_NAMESPACE
+inline static bool isPowerOfTwo(int x)
+{
+ // Assumption: x >= 1
+ return x == (x & -x);
+}
+
QSGTexturePrivate::QSGTexturePrivate()
: wrapChanged(false)
, filteringChanged(false)
@@ -252,6 +258,15 @@ void QSGTexture::updateBindOptions(bool force)
}
if (force || d->wrapChanged) {
+#if !defined(QT_NO_DEBUG) && defined(QT_OPENGL_ES_2)
+ if (d->horizontalWrap == Repeat || d->verticalWrap == Repeat) {
+ bool npotSupported = QGLContext::currentContext()->functions()->hasOpenGLFeature(QGLFunctions::NPOTTextures);
+ QSize size = textureSize();
+ bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
+ if (!npotSupported && isNpot)
+ qWarning("Scene Graph: This system does not support the REPEAT wrap mode for non-power-of-two textures.");
+ }
+#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, d->horizontalWrap == Repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, d->verticalWrap == Repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE);
d->wrapChanged = false;