diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 5b716d6bb..5209a089e 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -169,7 +169,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, if (pwidth <= 0 || pheight <= 0) return; - + palette = HWR_GetTexturePalette(); ncols = pwidth; @@ -219,7 +219,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, if (texture->width <= 0 || texture->height <= 0) return; - + palette = HWR_GetTexturePalette(); x1 = patch->originx; @@ -316,7 +316,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(); @@ -350,7 +350,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); @@ -426,7 +426,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; @@ -645,7 +645,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; @@ -919,8 +919,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); @@ -938,7 +938,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 @@ -990,11 +990,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 @@ -1004,8 +1002,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++) @@ -1053,7 +1053,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 1c72d62d1..07a6c9e5a 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}, @@ -282,7 +282,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 6d894419f..0630ccd2d 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -227,7 +227,7 @@ "gl_FragColor = final_color;\n" \ "}\n" \ "#endif\0" - + #define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \ "uniform sampler2D tex;\n" \ "uniform vec4 poly_color;\n" \ @@ -266,7 +266,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