[Scummvm-git-logs] scummvm master -> 6f3b535752c4cecb55fc653fb17eef194693d406

aquadran noreply at scummvm.org
Mon Nov 29 21:34:19 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6f3b535752 GRIM,STARK,TINYGL: Fixed BE drawing issues.


Commit: 6f3b535752c4cecb55fc653fb17eef194693d406
    https://github.com/scummvm/scummvm/commit/6f3b535752c4cecb55fc653fb17eef194693d406
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2021-11-29T22:34:13+01:00

Commit Message:
GRIM,STARK,TINYGL: Fixed BE drawing issues.

Changed paths:
    engines/grim/gfx_tinygl.cpp
    engines/stark/gfx/tinygltexture.cpp
    graphics/tinygl/texture.cpp


diff --git a/engines/grim/gfx_tinygl.cpp b/engines/grim/gfx_tinygl.cpp
index 53a2ee9776..cda5ec2438 100644
--- a/engines/grim/gfx_tinygl.cpp
+++ b/engines/grim/gfx_tinygl.cpp
@@ -909,7 +909,34 @@ void GfxTinyGL::createBitmap(BitmapData *bitmap) {
 		for (int i = 0; i < bitmap->_numImages; ++i) {
 			imgs[i] = Graphics::tglGenBlitImage();
 			const Graphics::Surface &imageBuffer = bitmap->getImageData(i);
-			Graphics::tglUploadBlitImage(imgs[i], imageBuffer, imageBuffer.format.ARGBToColor(0, 255, 0, 255), true);
+#ifdef SCUMM_BIG_ENDIAN
+			if (g_grim->getGameType() == GType_MONKEY4 && imageBuffer.format.bytesPerPixel == 2) {
+				Graphics::Surface buffer;
+				buffer.create(bitmap->_width, bitmap->_height, imageBuffer.format);
+				uint16 *bufSrc = (uint16 *)const_cast<void *>(imageBuffer.getPixels());
+				uint16 *bufDst = (uint16 *)(buffer.getPixels());
+				for (int f = 0; f < (bitmap->_width * bitmap->_height); f++) {
+					uint16 val = SWAP_BYTES_16(bufSrc[f]);
+					bufDst[f] = val;
+				}
+				Graphics::tglUploadBlitImage(imgs[i], buffer, buffer.format.ARGBToColor(0, 255, 0, 255), true);
+				buffer.free();
+			} else if (g_grim->getGameType() == GType_MONKEY4 && imageBuffer.format.bytesPerPixel == 4) {
+				Graphics::Surface buffer;
+				buffer.create(bitmap->_width, bitmap->_height, imageBuffer.format);
+				uint32 *bufSrc = (uint32 *)const_cast<void *>(imageBuffer.getPixels());
+				uint32 *bufDst = (uint32 *)(buffer.getPixels());
+				for (int f = 0; f < (bitmap->_width * bitmap->_height); f++) {
+					uint32 val = SWAP_BYTES_32(bufSrc[f]);
+					bufDst[f] = val;
+				}
+				Graphics::tglUploadBlitImage(imgs[i], buffer, buffer.format.ARGBToColor(0, 255, 0, 255), true);
+				buffer.free();
+			} else
+#endif
+			{
+				Graphics::tglUploadBlitImage(imgs[i], imageBuffer, imageBuffer.format.ARGBToColor(0, 255, 0, 255), true);
+			}
 		}
 	}
 }
diff --git a/engines/stark/gfx/tinygltexture.cpp b/engines/stark/gfx/tinygltexture.cpp
index 7a8bec652f..e2b64c213d 100644
--- a/engines/stark/gfx/tinygltexture.cpp
+++ b/engines/stark/gfx/tinygltexture.cpp
@@ -60,7 +60,7 @@ void TinyGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface,
 
 	if (surface->format.bytesPerPixel != 4) {
 		// Convert the surface to texture format
-		Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), palette);
+		Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
 
 		tglTexImage2D(TGL_TEXTURE_2D, 0, TGL_RGBA, convertedSurface->w, convertedSurface->h, 0, TGL_RGBA, TGL_UNSIGNED_BYTE, (char *)(convertedSurface->getPixels()));
 
@@ -68,16 +68,7 @@ void TinyGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface,
 		delete convertedSurface;
 	} else {
 		// Convert the surface to texture format
-		if (surface->format != Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) {
-			Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
-
-			tglTexImage2D(TGL_TEXTURE_2D, 0, TGL_RGBA, convertedSurface->w, convertedSurface->h, 0, TGL_RGBA, TGL_UNSIGNED_BYTE, (char *)(convertedSurface->getPixels()));
-
-			convertedSurface->free();
-			delete convertedSurface;
-		} else {
-			tglTexImage2D(TGL_TEXTURE_2D, 0, TGL_RGBA, surface->w, surface->h, 0, TGL_RGBA, TGL_UNSIGNED_BYTE, const_cast<void *>(surface->getPixels()));
-		}
+		tglTexImage2D(TGL_TEXTURE_2D, 0, TGL_RGBA, surface->w, surface->h, 0, TGL_RGBA, TGL_UNSIGNED_BYTE, const_cast<void *>(surface->getPixels()));
 	}
 }
 
diff --git a/graphics/tinygl/texture.cpp b/graphics/tinygl/texture.cpp
index 56738e63f0..885ce6dc1a 100644
--- a/graphics/tinygl/texture.cpp
+++ b/graphics/tinygl/texture.cpp
@@ -45,9 +45,7 @@ static const struct tglColorAssociation colorAssociationList[] = {
  * Note: this does not matter at all for TinyGL, but this is to be consistent
  * with future OpenGL equivalent for this code.
  */
-// TODO: remove pixel endianness conversions from tinygl callers and enable
-//#if defined(SCUMM_LITTLE_ENDIAN)
-#if 1
+#if defined(SCUMM_LITTLE_ENDIAN)
 	{Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), TGL_RGBA, TGL_UNSIGNED_BYTE},
 	{Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24), TGL_BGRA, TGL_UNSIGNED_BYTE},
 	{Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0),  TGL_RGB,  TGL_UNSIGNED_BYTE},




More information about the Scummvm-git-logs mailing list