Properly detect the max texture size when using QOpenGLPaintDevice.
The value is currently hard-coded to 1024, this is a problem since any image painted with a size higher that this will be scaled down before being uploaded. This patch copies the implementation from QGLContext which works correctly. Change-Id: Ia2bda60cf21d9adf13c91cea4854a2b20e4041f2 Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>
This commit is contained in:
parent
3709d8dc52
commit
e78b3e80e6
@ -161,6 +161,40 @@ void QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context)
|
||||
threadContext->context = context;
|
||||
}
|
||||
|
||||
int QOpenGLContextPrivate::maxTextureSize()
|
||||
{
|
||||
if (max_texture_size != -1)
|
||||
return max_texture_size;
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||||
|
||||
#if defined(QT_OPENGL_ES)
|
||||
return max_texture_size;
|
||||
#else
|
||||
GLenum proxy = GL_PROXY_TEXTURE_2D;
|
||||
|
||||
GLint size;
|
||||
GLint next = 64;
|
||||
glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &size);
|
||||
if (size == 0) {
|
||||
return max_texture_size;
|
||||
}
|
||||
do {
|
||||
size = next;
|
||||
next = size * 2;
|
||||
|
||||
if (next > max_texture_size)
|
||||
break;
|
||||
glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &next);
|
||||
} while (next > size);
|
||||
|
||||
max_texture_size = size;
|
||||
return max_texture_size;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the last context which called makeCurrent in the current thread,
|
||||
or 0, if no context is current.
|
||||
|
@ -189,6 +189,7 @@ public:
|
||||
, surface(0)
|
||||
, functions(0)
|
||||
, current_fbo(0)
|
||||
, max_texture_size(-1)
|
||||
, workaround_brokenFBOReadBack(false)
|
||||
, workaround_brokenTexSubImage(false)
|
||||
, active_engine(0)
|
||||
@ -213,6 +214,7 @@ public:
|
||||
QOpenGLFunctions *functions;
|
||||
|
||||
GLuint current_fbo;
|
||||
GLint max_texture_size;
|
||||
|
||||
bool workaround_brokenFBOReadBack;
|
||||
bool workaround_brokenTexSubImage;
|
||||
@ -221,7 +223,7 @@ public:
|
||||
|
||||
static void setCurrentContext(QOpenGLContext *context);
|
||||
|
||||
int maxTextureSize() const { return 1024; }
|
||||
int maxTextureSize();
|
||||
|
||||
#if !defined(QT_NO_DEBUG)
|
||||
static bool toggleMakeCurrentTracker(QOpenGLContext *context, bool value)
|
||||
|
Loading…
Reference in New Issue
Block a user