From e873d11187780b50364a1f0f086ee46fb93d8fd2 Mon Sep 17 00:00:00 2001 From: gewlitys Date: Tue, 17 Dec 2002 16:24:39 +0000 Subject: [PATCH] Fix OpenGL colors on big-endian CPUs, from Bryce McKinley git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@430 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/graphics/sdl/opengl.c | 17 +++++++++++++---- sc2/src/sc2code/libs/graphics/sdl/sdl_common.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sc2/src/sc2code/libs/graphics/sdl/opengl.c b/sc2/src/sc2code/libs/graphics/sdl/opengl.c index 7928265f2..8bef1a942 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/opengl.c +++ b/sc2/src/sc2code/libs/graphics/sdl/opengl.c @@ -28,6 +28,15 @@ static unsigned int TransitionTexture; static BOOLEAN scanlines; static BOOLEAN upload_transitiontexture = FALSE; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN +#define R_MASK 0x00ff0000 +#define G_MASK 0x0000ff00 +#define B_MASK 0x000000ff +#else +#define R_MASK 0x000000ff +#define G_MASK 0x0000ff00 +#define B_MASK 0x00ff0000 +#endif int TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp) @@ -114,7 +123,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp) } SDL_Screen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 24, - 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000); + R_MASK, G_MASK, B_MASK, 0x00000000); if (SDL_Screen == NULL) { @@ -123,7 +132,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp) } ExtraScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 24, - 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000); + R_MASK, G_MASK, B_MASK, 0x00000000); if (ExtraScreen == NULL) { @@ -132,7 +141,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp) } TransitionScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 24, - 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000); + R_MASK, G_MASK, B_MASK, 0x00000000); if (TransitionScreen == NULL) { @@ -141,7 +150,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp) } format_conv_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32, - 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); + R_MASK, G_MASK, B_MASK, 0x00000000); if (format_conv_surf == NULL) { diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.h b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.h index f64da7097..cade7bae8 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.h +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.h @@ -21,6 +21,7 @@ #include "SDL.h" #include "SDL_image.h" +#include "SDL_byteorder.h" #include "libs/graphics/gfxintrn.h" #include "libs/input/inpintrn.h"