From 84bedab2759dff5846832b11780f11bb5e3c99c6 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 24 Jun 2020 19:53:54 -0700 Subject: [PATCH] HD Remaster Terrain tiles now go into the cache. --- code/REDALERT/TEXCACHE.CPP | 4 ++-- code/REDALERT/WINSTUB.CPP | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/code/REDALERT/TEXCACHE.CPP b/code/REDALERT/TEXCACHE.CPP index c4d8924..440d0da 100644 --- a/code/REDALERT/TEXCACHE.CPP +++ b/code/REDALERT/TEXCACHE.CPP @@ -4,8 +4,8 @@ #include "FUNCTION.H" #include "TEXCACHE.H" -#define CACHE_HEADER_FILENAME "cache/cache_header_v1.vhdr" -#define CACHE_DATA_FILERNAME "cache/cache_data_v1.vdata" +#define CACHE_HEADER_FILENAME "cache/cache_header_v2.vhdr" +#define CACHE_DATA_FILERNAME "cache/cache_data_v2.vdata" TexCache texCache; diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index 4acc475..35cb38e 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -176,7 +176,7 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int // Check to see if we can load a generated image first. // We only generate images that need a houseid - if (houseid >= 0) { + { if (Image_LoadFromCache(image, generatedName, houseid, animid, frameId, hash)) { return true; } @@ -191,10 +191,8 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int return false; } - bool swapBGR = false; if (strstr(name, ".TGA") || strstr(name, ".tga")) { iluFlipImage(); - swapBGR = true; } ILuint Width, Height, Bpp; @@ -213,18 +211,20 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int RenderTeamPalette(&Data[i * 4], *houseColors[houseid]); } } + else if (Bpp == 4) { + for (int i = 0; i < Width * Height; i++) { + byte b = Data[(i * 4) + 2]; + Data[(i * 4) + 2] = Data[(i * 4) + 0]; + Data[(i * 4) + 0] = b; + } + } GLuint texture; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); if (Bpp == 4) { - if (swapBGR) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, Data); - } - else { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data); - } + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, Data); } else if (Bpp == 3) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, Data); @@ -252,7 +252,7 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int //image->buffer[houseid][animid] = new unsigned char[Width * Height * Bpp]; //memcpy(image->buffer[houseid][animid], Data, Width * Height * Bpp); - if (Bpp == 4 && houseid >= 0) { + if (Bpp == 4) { texCache.AddImage(generatedName, Width, Height, Bpp, Data); Console_Printf("Writing %s to cache %s\n", image->name, name); Sleep(0);