diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 9f02007d4..08bcfd10f 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -166,7 +166,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, if (pwidth <= 0 || pheight <= 0) return; - + palette = HWR_GetTexturePalette(); ncols = pwidth; @@ -216,7 +216,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, if (texture->width <= 0 || texture->height <= 0) return; - + palette = HWR_GetTexturePalette(); x1 = patch->originx; @@ -313,7 +313,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe INT32 i; boolean skyspecial = false; //poor hack for Legacy large skies.. - + RGBA_t *palette; palette = HWR_GetTexturePalette(); @@ -347,7 +347,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe if (encoremap && !noencore) grtex->mipmap.colormap += COLORMAP_REMAPOFFSET; #endif - + blockwidth = texture->width; blockheight = texture->height; blocksize = (blockwidth * blockheight); @@ -423,7 +423,7 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, bo grMipmap->flags = 0; // setup the texture info grMipmap->format = patchformat; - + //grPatch->max_s = grPatch->max_t = 1.0f; grPatch->max_s = (float)grPatch->width / (float)grMipmap->width; grPatch->max_t = (float)grPatch->height / (float)grMipmap->height; @@ -642,7 +642,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) { GLMipmap_t *grmip; - + if (flatlumpnum == LUMPERROR) return; @@ -916,8 +916,8 @@ void HWR_SetPalette(RGBA_t *palette) // the 16-bit version! For making comparison screenshots either use an external screenshot // tool or set the palette depth to 24 bits. RGBA_t crushed_palette[256]; - int i; - for (i = 0; i < 256; i++) + + for (int i = 0; i < 256; i++) { float fred = (float)(palette[i].s.red >> 3); float fgreen = (float)(palette[i].s.green >> 2); @@ -935,7 +935,7 @@ void HWR_SetPalette(RGBA_t *palette) } // this part is responsible for keeping track of the palette OUTSIDE of a level. - if ((!(gamestate == GS_LEVEL)) || (gamestate == GS_TITLESCREEN)) + if (gamestate != GS_LEVEL || gamestate == GS_TITLESCREEN) HWR_SetMapPalette(); } else @@ -987,11 +987,9 @@ void HWR_SetMapPalette(void) RGBA_t *palette; int i; - if ((!(gamestate == GS_LEVEL)) || (gamestate == GS_TITLESCREEN)) + if (gamestate != GS_LEVEL || gamestate == GS_TITLESCREEN) { - // outside of a level, pMasterPalette should have PLAYPAL ready for us - //palette = pMasterPalette; // we dont have this in kart so just use pLocalPalette as before - + // outside of a level, pLocalPalette should have PLAYPAL ready for us palette = pLocalPalette; } else @@ -1001,8 +999,10 @@ void HWR_SetMapPalette(void) lumpnum_t lumpnum = W_GetNumForName(GetPalette()); size_t palsize = W_LumpLength(lumpnum); UINT8 *RGB_data; + if (palsize < 768) // 256 * 3 I_Error("HWR_SetMapPalette: A programmer assumed palette lumps are at least 768 bytes long, but apparently this was a wrong assumption!\n"); + RGB_data = W_CacheLumpNum(lumpnum, PU_CACHE); // we got the RGB palette now, but we need it in RGBA format. for (i = 0; i < 256; i++) @@ -1050,7 +1050,6 @@ UINT32 HWR_CreateLightTable(UINT8 *lighttable) return id; } - // get hwr lighttable id for colormap, create it if it doesn't already exist UINT32 HWR_GetLightTableID(extracolormap_t *colormap) { diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index ee0fd0b85..41fda57d0 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -593,12 +593,12 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) { RGBA_t *palette = HWR_GetTexturePalette(); Surf.PolyColor.rgba = palette[color&0xFF].rgba; - + if (HWR_ShouldUsePaletteRendering()) Surf.PolyColor.s.alpha = softwaretranstogl[strength]; else Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f); - + poly_flags |= PF_Translucent; } @@ -776,9 +776,9 @@ void HWR_drawAMline(const fline_t *fl, INT32 color) F2DCoord v1, v2; RGBA_t color_rgba; RGBA_t *palette = HWR_GetTexturePalette(); - + color_rgba = palette[color&0xFF]; - + v1.x = ((float)fl->a.x-(vid.width/2.0f))*(2.0f/vid.width); v1.y = ((float)fl->a.y-(vid.height/2.0f))*(2.0f/vid.height); diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index d7924a675..980a8342d 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -25,7 +25,7 @@ static struct { const char *vertex; const char *fragment; } const gl_shadersources[] = { - + // Floor shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER}, @@ -52,7 +52,7 @@ static struct { // Palette postprocess shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_PALETTE_POSTPROCESS_FRAGMENT_SHADER}, - + // UI colormap fade shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_UI_COLORMAP_FADE_FRAGMENT_SHADER}, @@ -279,7 +279,7 @@ static char *HWR_PreprocessShader(char *original) // Calculate length of modified shader. new_len = original_len; - + if (cv_grpaletterendering.value) ADD_TO_LEN(PALETTE_RENDERING_DEFINE) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 714b004b1..77a93eb2e 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -171,7 +171,7 @@ "gl_FragColor = final_color;\n" \ "}\n" \ "#endif\0" - + #define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \ "uniform sampler2D tex;\n" \ "uniform vec4 poly_color;\n" \ @@ -210,7 +210,7 @@ #define GLSL_WALL_FRAGMENT_SHADER \ GLSL_WALL_FUDGES \ GLSL_SOFTWARE_FRAGMENT_SHADER - + #define GLSL_SHADOW_FRAGMENT_SHADER \ GLSL_FLOOR_FUDGES \ GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL