From 4f1d6630a96ea7c13073e3ef55e6b36f6029fc83 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 26 Nov 2007 22:05:56 +0000 Subject: [PATCH] added support for TEXTYPE_BGRA (GL_BGRA format), this doesn't require any difference in processing functions, but the initial data must be encoded accordingly this format was added because it uploads faster on some hardware, and the engine will be migrating over to using it git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7717 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_textures.c | 13 +++++++++++++ r_textures.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/gl_textures.c b/gl_textures.c index 24c9d69f..976946b8 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -49,12 +49,16 @@ textypeinfo_t; static textypeinfo_t textype_palette = {TEXTYPE_PALETTE, 1, 4, 4.0f, GL_RGBA , 3}; static textypeinfo_t textype_rgba = {TEXTYPE_RGBA , 4, 4, 4.0f, GL_RGBA , 3}; +static textypeinfo_t textype_bgra = {TEXTYPE_BGRA , 4, 4, 4.0f, GL_BGRA , 3}; static textypeinfo_t textype_palette_alpha = {TEXTYPE_PALETTE, 1, 4, 4.0f, GL_RGBA , 4}; static textypeinfo_t textype_rgba_alpha = {TEXTYPE_RGBA , 4, 4, 4.0f, GL_RGBA , 4}; +static textypeinfo_t textype_bgra_alpha = {TEXTYPE_BGRA , 4, 4, 4.0f, GL_BGRA , 4}; static textypeinfo_t textype_palette_compress = {TEXTYPE_PALETTE, 1, 4, 0.5f, GL_RGBA , GL_COMPRESSED_RGB_ARB}; static textypeinfo_t textype_rgba_compress = {TEXTYPE_RGBA , 4, 4, 0.5f, GL_RGBA , GL_COMPRESSED_RGB_ARB}; +static textypeinfo_t textype_bgra_compress = {TEXTYPE_BGRA , 4, 4, 0.5f, GL_BGRA , GL_COMPRESSED_RGB_ARB}; static textypeinfo_t textype_palette_alpha_compress = {TEXTYPE_PALETTE, 1, 4, 1.0f, GL_RGBA , GL_COMPRESSED_RGBA_ARB}; static textypeinfo_t textype_rgba_alpha_compress = {TEXTYPE_RGBA , 4, 4, 1.0f, GL_RGBA , GL_COMPRESSED_RGBA_ARB}; +static textypeinfo_t textype_bgra_alpha_compress = {TEXTYPE_BGRA , 4, 4, 1.0f, GL_BGRA , GL_COMPRESSED_RGBA_ARB}; #define GLTEXTURETYPE_1D 0 #define GLTEXTURETYPE_2D 1 @@ -152,6 +156,8 @@ static textypeinfo_t *R_GetTexTypeInfo(int textype, int flags) return &textype_palette_alpha_compress; case TEXTYPE_RGBA: return &textype_rgba_alpha_compress; + case TEXTYPE_BGRA: + return &textype_bgra_alpha_compress; default: Host_Error("R_GetTexTypeInfo: unknown texture format"); return NULL; @@ -165,6 +171,8 @@ static textypeinfo_t *R_GetTexTypeInfo(int textype, int flags) return &textype_palette_compress; case TEXTYPE_RGBA: return &textype_rgba_compress; + case TEXTYPE_BGRA: + return &textype_bgra_compress; default: Host_Error("R_GetTexTypeInfo: unknown texture format"); return NULL; @@ -181,6 +189,8 @@ static textypeinfo_t *R_GetTexTypeInfo(int textype, int flags) return &textype_palette_alpha; case TEXTYPE_RGBA: return &textype_rgba_alpha; + case TEXTYPE_BGRA: + return &textype_bgra_alpha; default: Host_Error("R_GetTexTypeInfo: unknown texture format"); return NULL; @@ -194,6 +204,8 @@ static textypeinfo_t *R_GetTexTypeInfo(int textype, int flags) return &textype_palette; case TEXTYPE_RGBA: return &textype_rgba; + case TEXTYPE_BGRA: + return &textype_bgra; default: Host_Error("R_GetTexTypeInfo: unknown texture format"); return NULL; @@ -981,6 +993,7 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden } break; case TEXTYPE_RGBA: + case TEXTYPE_BGRA: if (flags & TEXF_ALPHA) { flags &= ~TEXF_ALPHA; diff --git a/r_textures.h b/r_textures.h index 4df426a6..4ad5f5e8 100644 --- a/r_textures.h +++ b/r_textures.h @@ -27,6 +27,8 @@ #define TEXTYPE_PALETTE 1 // 32bit RGBA #define TEXTYPE_RGBA 3 +// 32bit BGRA (preferred format due to faster uploads on most hardware) +#define TEXTYPE_BGRA 4 // contents of this structure are mostly private to gl_textures.c typedef struct rtexture_s -- 2.39.2