mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-26 06:18:23 +00:00
Merge pull request #302 from clone2727/gl-linear-fix
OPENGL: Fix linear filtering when the texture size doesn't match the real size
This commit is contained in:
commit
fefa3bdd3f
@ -108,9 +108,18 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) {
|
||||
_realWidth = w;
|
||||
_realHeight = h;
|
||||
|
||||
if (w <= _textureWidth && h <= _textureHeight && !_refresh)
|
||||
// Already allocated a sufficiently large buffer
|
||||
return;
|
||||
if (!_refresh) {
|
||||
if (npot_supported && _filter == GL_LINEAR) {
|
||||
// Check if we already allocated a correctly-sized buffer
|
||||
// This is so we don't need to duplicate the last row/column
|
||||
if (w == _textureWidth && h == _textureHeight)
|
||||
return;
|
||||
} else {
|
||||
// Check if we already have a large enough buffer
|
||||
if (w <= _textureWidth && h <= _textureHeight)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (npot_supported) {
|
||||
_textureWidth = w;
|
||||
@ -151,12 +160,37 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu
|
||||
} else {
|
||||
// Update the texture row by row
|
||||
const byte *src = (const byte *)buf;
|
||||
GLuint curY = y;
|
||||
GLuint height = h;
|
||||
do {
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y,
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, curY,
|
||||
w, 1, _glFormat, _glType, src); CHECK_GL_ERROR();
|
||||
++y;
|
||||
curY++;
|
||||
src += pitch;
|
||||
} while (--h);
|
||||
} while (--height);
|
||||
}
|
||||
|
||||
// If we're in linear filter mode, repeat the last row/column if the real dimensions
|
||||
// doesn't match the texture dimensions.
|
||||
if (_filter == GL_LINEAR) {
|
||||
if (_realWidth != _textureWidth && x + w == _realWidth) {
|
||||
const byte *src = (const byte *)buf + (w - 1) * _bytesPerPixel;
|
||||
GLuint curY = y;
|
||||
GLuint height = h;
|
||||
|
||||
do {
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x + w,
|
||||
curY, 1, 1, _glFormat, _glType, src); CHECK_GL_ERROR();
|
||||
|
||||
curY++;
|
||||
src += pitch;
|
||||
} while (--height);
|
||||
}
|
||||
|
||||
if (_realHeight != _textureHeight && y + h == _realHeight) {
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y + h,
|
||||
w, 1, _glFormat, _glType, (const byte *)buf + pitch * (h - 1)); CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user