From 35559a2f00fc9bf609144a6bba3f0a678f61cd12 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 11 May 2011 17:46:06 +0200 Subject: [PATCH] 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. --- src/declarative/scenegraph/util/qsgtexture.cpp | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/src/declarative/scenegraph/util/qsgtexture.cpp b/src/declarative/scenegraph/util/qsgtexture.cpp index 9362ba8..c82f214 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; -- 1.7.2.5