diff --git a/engines/myst3/gfx_tinygl_texture.cpp b/engines/myst3/gfx_tinygl_texture.cpp index a753db5115a..36d52eb08d9 100644 --- a/engines/myst3/gfx_tinygl_texture.cpp +++ b/engines/myst3/gfx_tinygl_texture.cpp @@ -54,7 +54,7 @@ TinyGLTexture::TinyGLTexture(const Graphics::Surface *surface, bool nonPoTSuppor if (format.bytesPerPixel == 4) { internalFormat = TGL_RGBA; - sourceFormat = TGL_UNSIGNED_BYTE; + sourceFormat = TGL_UNSIGNED_INT_8_8_8_8_REV; } else if (format.bytesPerPixel == 2) { internalFormat = TGL_RGB; sourceFormat = TGL_UNSIGNED_BYTE; // UNSIGNED_SHORT_5_6_5 not provided diff --git a/graphics/tinygl/gl.h b/graphics/tinygl/gl.h index 5205d672940..24b0f5ff978 100644 --- a/graphics/tinygl/gl.h +++ b/graphics/tinygl/gl.h @@ -585,6 +585,10 @@ enum { TGL_RGB10_A2 = 0x8059, TGL_RGBA12 = 0x805A, TGL_RGBA16 = 0x805B, + TGL_UNSIGNED_SHORT_5_6_5 = 0x8363, + TGL_UNSIGNED_SHORT_5_6_5_REV = 0x8364, + TGL_UNSIGNED_INT_8_8_8_8 = 0x8035, + TGL_UNSIGNED_INT_8_8_8_8_REV = 0x8367, // Utility TGL_VENDOR = 0x1F00, diff --git a/graphics/tinygl/texture.cpp b/graphics/tinygl/texture.cpp index cbda0085217..1c583cd959f 100644 --- a/graphics/tinygl/texture.cpp +++ b/graphics/tinygl/texture.cpp @@ -28,6 +28,8 @@ // Texture Manager +#include "common/endian.h" + #include "graphics/tinygl/zgl.h" namespace TinyGL { @@ -177,7 +179,12 @@ void glopTexImage2D(GLContext *c, GLParam *p) { pixels = temp.getRawBuffer(); do_free_after_rgb2rgba = true; } - } else if ((format != TGL_RGBA && format != TGL_RGB && format != TGL_BGR) || type != TGL_UNSIGNED_BYTE) { + } else if ((format != TGL_RGBA && + format != TGL_RGB && + format != TGL_BGR && + format != TGL_BGRA) || + (type != TGL_UNSIGNED_BYTE && + type != TGL_UNSIGNED_INT_8_8_8_8_REV)) { error("tglTexImage2D: combination of parameters not handled"); } @@ -191,6 +198,17 @@ void glopTexImage2D(GLContext *c, GLParam *p) { } else { memcpy(pixels1, pixels, c->_textureSize * c->_textureSize * bytes); } +#if defined(SCUMM_BIG_ENDIAN) + if (type == TGL_UNSIGNED_INT_8_8_8_8_REV) { + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + uint32 offset = (y * width + x) * 4; + byte *data = pixels1 + offset; + WRITE_BE_UINT32(data, READ_LE_UINT32(data)); + } + } + } +#endif } c->current_texture->versionNumber++;