Don't generate mipmaps in GLTexture::bind()
This code is broken in a number of different ways; firstly by assuming that the mipmaps need to be regenerated when the texture filter has changed. Secondly by preventing mipmaps from being specified by other means. This commit removes the code from bind() and adds a generateMipmaps() method instead.
This commit is contained in:
parent
5ac159d47e
commit
aefadfaa6a
4 changed files with 13 additions and 5 deletions
|
@ -357,6 +357,7 @@ void LogoutEffect::renderBlurTexture()
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
blurTexture->bind();
|
blurTexture->bind();
|
||||||
|
blurTexture->generateMipmaps();
|
||||||
blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry());
|
blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry());
|
||||||
blurTexture->unbind();
|
blurTexture->unbind();
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
|
@ -239,6 +239,7 @@ void LookingGlassEffect::postPaintScreen()
|
||||||
assert(target == m_fbo);
|
assert(target == m_fbo);
|
||||||
Q_UNUSED(target);
|
Q_UNUSED(target);
|
||||||
m_texture->bind();
|
m_texture->bind();
|
||||||
|
m_texture->generateMipmaps();
|
||||||
|
|
||||||
// Use the shader
|
// Use the shader
|
||||||
ShaderBinder binder(m_shader);
|
ShaderBinder binder(m_shader);
|
||||||
|
|
|
@ -283,7 +283,6 @@ void GLTexture::update(const QImage &image, const QPoint &offset, const QRect &s
|
||||||
}
|
}
|
||||||
|
|
||||||
unbind();
|
unbind();
|
||||||
setDirty();
|
|
||||||
|
|
||||||
if (useUnpack) {
|
if (useUnpack) {
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
@ -312,7 +311,6 @@ void GLTexture::bind()
|
||||||
if (d->s_supportsFramebufferObjects && d->m_canUseMipmaps) {
|
if (d->s_supportsFramebufferObjects && d->m_canUseMipmaps) {
|
||||||
glTexParameteri(d->m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(d->m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
glTexParameteri(d->m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(d->m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glGenerateMipmap(d->m_target);
|
|
||||||
} else {
|
} else {
|
||||||
// can't use trilinear, so use bilinear
|
// can't use trilinear, so use bilinear
|
||||||
d->m_filter = GL_LINEAR;
|
d->m_filter = GL_LINEAR;
|
||||||
|
@ -337,6 +335,14 @@ void GLTexture::bind()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLTexture::generateMipmaps()
|
||||||
|
{
|
||||||
|
Q_D(GLTexture);
|
||||||
|
|
||||||
|
if (d->m_canUseMipmaps && d->s_supportsFramebufferObjects)
|
||||||
|
glGenerateMipmap(d->m_target);
|
||||||
|
}
|
||||||
|
|
||||||
void GLTexture::unbind()
|
void GLTexture::unbind()
|
||||||
{
|
{
|
||||||
Q_D(GLTexture);
|
Q_D(GLTexture);
|
||||||
|
@ -460,9 +466,7 @@ void GLTexture::setWrapMode(GLenum mode)
|
||||||
|
|
||||||
void GLTexturePrivate::onDamage()
|
void GLTexturePrivate::onDamage()
|
||||||
{
|
{
|
||||||
if (m_filter == GL_LINEAR_MIPMAP_LINEAR && !m_filterChanged) {
|
// No-op
|
||||||
glGenerateMipmap(m_target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLTexture::setDirty()
|
void GLTexture::setDirty()
|
||||||
|
|
|
@ -101,6 +101,8 @@ public:
|
||||||
void setWrapMode(GLenum mode);
|
void setWrapMode(GLenum mode);
|
||||||
void setDirty();
|
void setDirty();
|
||||||
|
|
||||||
|
void generateMipmaps();
|
||||||
|
|
||||||
static bool framebufferObjectSupported();
|
static bool framebufferObjectSupported();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in a new issue