TETRAEDGE: Clean right side of textures if they are non-power-2 size

Speculative fix for bug #14539.
This commit is contained in:
Matthew Duggan 2023-08-19 15:36:54 +09:00
parent 78762a2a46
commit e01f0a1ce9

View File

@ -118,7 +118,7 @@ bool Te3DTextureOpenGL::load(const TeImage &img) {
_format = img.teFormat();
// TODO? set some other fields from the image here.
// for now just set some good defaults.
// For now just set defaults as these never get used in games.
_flipY = true; //img._flipY;
_leftBorder = 0; //img._leftBorder;
_btmBorder = 0; //img._btmBorder;
@ -162,6 +162,7 @@ bool Te3DTextureOpenGL::load(const TeImage &img) {
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, _texWidth, _texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, img.w, img.h, GL_RGBA, GL_UNSIGNED_BYTE, imgdata);
// FIXME: Slight hack.. sometimes artifacts appear because we draw
// a (half?)pixel outside the original texture. Clear one more row
// of the new texture with 0s to avoid artifacts.
@ -171,6 +172,14 @@ bool Te3DTextureOpenGL::load(const TeImage &img) {
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, img.h, img.w, 1, GL_RGBA, GL_UNSIGNED_BYTE, buf);
delete [] buf;
}
// And the same for the right-hand-side
if ((int)_texWidth > img.w) {
byte *buf = new byte[img.h * 4];
memset(buf, 0, img.h * 4);
glTexSubImage2D(GL_TEXTURE_2D, 0, img.w, 0, 1, img.h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
delete [] buf;
}
if (_alphaOnly)
surf.free();
} else {