MYST3, TINYGL: fixed endian issue

This commit is contained in:
Pawel Kolodziejski 2014-12-23 20:39:38 +01:00
parent 7a3e61a9b7
commit c2a9a394c3
3 changed files with 24 additions and 2 deletions

View File

@ -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

View File

@ -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,

View File

@ -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++;