diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c32870fed..1fdd88ad3 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -502,6 +502,9 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) // Set the first colormap to the one that comes after it. next = pat->mipmap->nextcolormap; + if (!next) + break; + pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. @@ -646,6 +649,9 @@ 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; grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; @@ -662,7 +668,6 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grmip->downloaded) HWD.pfnSetTexture(grmip); - HWR_SetCurrentTexture(grmip); // The system-memory data can be purged now. @@ -1085,8 +1090,7 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap) // call become invalid and must not be used. void HWR_ClearLightTables(void) { - //if (vid.glstate == VID_GL_LIBRARY_LOADED) // we have pfnInit which is essentially the same, but it doesent work here for whatever reason, since this should not be done in software renderer ever! - if (rendermode == render_opengl) + if (vid.glstate == VID_GL_LIBRARY_LOADED) HWD.pfnClearLightTables(); } diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index df4d431f9..7d58dc495 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -59,7 +59,7 @@ EXPORT void HWRAPI(FlushScreenTextures) (void); EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd); EXPORT void HWRAPI(DrawScreenTexture) (int tex, FSurfaceInfo *surf, FBITFIELD polyflags); EXPORT void HWRAPI(MakeScreenTexture) (int tex); -EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, int width, int height); +EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, INT32 width, INT32 height); EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e420119b3..2ca8f2a79 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -161,7 +161,6 @@ consvar_t cv_grfakecontrast = {"gr_fakecontrast", "Standard", CV_SAVE, grfakecon consvar_t cv_grslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - #define ONLY_IF_GL_LOADED if (vid.glstate != VID_GL_LIBRARY_LOADED) return; @@ -2669,7 +2668,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; + Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); } if (gr_backsector->numlights) @@ -6699,7 +6698,7 @@ void HWR_MakeScreenFinalTexture(void) HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); } -void HWR_DrawScreenFinalTexture(int width, int height) +void HWR_DrawScreenFinalTexture(INT32 width, INT32 height) { HWD.pfnDrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height); } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4725c720b..018f1bfbd 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -115,7 +115,7 @@ void HWR_DrawIntermissionBG(void); void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); void HWR_MakeScreenFinalTexture(void); -void HWR_DrawScreenFinalTexture(int width, int height); +void HWR_DrawScreenFinalTexture(INT32 width, INT32 height); // hw_main.c: Planes void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index eb705c34c..efd908226 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -76,7 +76,7 @@ #define GLSL_SOFTWARE_TINT_EQUATION \ "if (tint_color.a > 0.0) {\n" \ "float color_bright = sqrt((base_color.r * base_color.r) + (base_color.g * base_color.g) + (base_color.b * base_color.b));\n" \ - "float strength = sqrt(9.0 * tint_color.a);\n" \ + "float strength = sqrt(tint_color.a);\n" \ "final_color.r = clamp((color_bright * (tint_color.r * strength)) + (base_color.r * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.g = clamp((color_bright * (tint_color.g * strength)) + (base_color.g * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.b = clamp((color_bright * (tint_color.b * strength)) + (base_color.b * (1.0 - strength)), 0.0, 1.0);\n" \