aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorJohannes Schickel2011-11-09 18:54:52 +0100
committerJohannes Schickel2011-11-09 18:57:13 +0100
commit949b30dc36efd4c25822f83c6869179ea0f36dd2 (patch)
tree1bb573206540e639b72a71dafb7495bd4b982f2b /backends
parent17027a7afc8db73ee136d481781fe4cdfd7ea7ef (diff)
downloadscummvm-rg350-949b30dc36efd4c25822f83c6869179ea0f36dd2.tar.gz
scummvm-rg350-949b30dc36efd4c25822f83c6869179ea0f36dd2.tar.bz2
scummvm-rg350-949b30dc36efd4c25822f83c6869179ea0f36dd2.zip
OPENGL: Always set the unpack alignment when refreshing the textures.
This should hopefully make sure we are always having the correct alignment set up. This might fix bug #3435655 "OpenGL display corruption with various Sierra games Daily B.".
Diffstat (limited to 'backends')
-rw-r--r--backends/graphics/opengl/gltexture.h5
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp12
2 files changed, 10 insertions, 7 deletions
diff --git a/backends/graphics/opengl/gltexture.h b/backends/graphics/opengl/gltexture.h
index 71f1eeb78f..d8c42eeb2d 100644
--- a/backends/graphics/opengl/gltexture.h
+++ b/backends/graphics/opengl/gltexture.h
@@ -103,6 +103,11 @@ public:
GLuint getHeight() const { return _realHeight; }
/**
+ * Get the bytes per pixel.
+ */
+ uint getBytesPerPixel() const { return _bytesPerPixel; }
+
+ /**
* Set the texture filter.
* @filter the filter type, GL_NEAREST or GL_LINEAR
*/
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 8e01e76f16..5b1f7b4b28 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1115,8 +1115,6 @@ void OpenGLGraphicsManager::loadTextures() {
}
#endif
- uint gameScreenBPP = 0;
-
if (!_gameTexture) {
byte bpp;
GLenum intformat;
@@ -1127,7 +1125,6 @@ void OpenGLGraphicsManager::loadTextures() {
#else
getGLPixelFormat(Graphics::PixelFormat::createFormatCLUT8(), bpp, intformat, format, type);
#endif
- gameScreenBPP = bpp;
_gameTexture = new GLTexture(bpp, intformat, format, type);
} else
_gameTexture->refresh();
@@ -1186,10 +1183,11 @@ void OpenGLGraphicsManager::loadTextures() {
// We need to setup a proper unpack alignment value here, else we will
// get problems with the texture updates, in case the surface data is
// not properly aligned.
- // For now we use the gcd of the game screen format and 2, since 2 is
- // the BPP value for the overlay and the OSD.
- if (gameScreenBPP)
- glPixelStorei(GL_UNPACK_ALIGNMENT, Common::gcd<uint>(gameScreenBPP, 2));
+ // It is noteworthy this assumes the OSD uses the same BPP as the overlay
+ // and that the cursor works with any alignment setting.
+ int newAlignment = Common::gcd(_gameTexture->getBytesPerPixel(), _overlayTexture->getBytesPerPixel());
+ assert(newAlignment == 1 || newAlignment == 2 || newAlignment == 4);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, newAlignment);
// We use a "pack" alignment (when reading from textures) to 4 here,
// since the only place where we really use it is the BMP screenshot