From 3eb741e3912f696751c1ef521a78fb72cadda858 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 24 Dec 2007 21:56:49 +0000 Subject: [PATCH] - added some functionality to FDynamicColormap to allow not creating the colormap data if it isn't needed by the renderer. SVN r635 (trunk) --- docs/rh-log.txt | 2 ++ src/v_font.cpp | 2 +- src/v_palette.cpp | 26 ++++++++++++++++++++++++-- src/v_palette.h | 1 + src/v_video.cpp | 5 +++++ src/v_video.h | 3 +++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 281b67718..f3aaa5362 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ December 24, 2007 (Changes by Graf Zahl) +- added some functionality to FDynamicColormap to allow not creating + the colormap data. - also replaced the AM crosshair drawer by a DCanvas::DrawPixel function. - moved the AM line drawer into DCanvas as a virtual function. While testing this code I discovered that the antialias precalculation was never used diff --git a/src/v_font.cpp b/src/v_font.cpp index 2831b1c80..7e17521bf 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -180,7 +180,7 @@ FFont * V_GetFont(const char *name) if (strlen(name) > 8) { fullname.Format("%s.fon", name); - lump = Wads.CheckNumForFullName(name); + lump = Wads.CheckNumForFullName(fullname); } else { diff --git a/src/v_palette.cpp b/src/v_palette.cpp index 95f4b6699..35f674a34 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -659,14 +659,18 @@ FDynamicColormap *GetSpecialLights (PalEntry color, PalEntry fade, int desaturat // Not found. Create it. colormap = new FDynamicColormap; - colormap->Maps = new BYTE[NUMCOLORMAPS*256]; colormap->Next = NormalLight.Next; colormap->Color = color; colormap->Fade = fade; colormap->Desaturate = desaturate; NormalLight.Next = colormap; - colormap->BuildLights (); + if (screen->UsesColormap()) + { + colormap->Maps = new BYTE[NUMCOLORMAPS*256]; + colormap->BuildLights (); + } + else colormap->Maps = NULL; return colormap; } @@ -788,6 +792,24 @@ void FDynamicColormap::ChangeColorFade (PalEntry lightcolor, PalEntry fadecolor) } } +void FDynamicColormap::RebuildAllLights() +{ + if (screen->UsesColormap()) + { + FDynamicColormap *cm; + + for (cm = &NormalLight; cm != NULL; cm = cm->Next) + { + if (cm->Maps == NULL) + { + cm->Maps = new BYTE[NUMCOLORMAPS*256]; + cm->BuildLights (); + } + } + } +} + + CCMD (testcolor) { FString colorstring; diff --git a/src/v_palette.h b/src/v_palette.h index 4f56078b6..146654ce1 100644 --- a/src/v_palette.h +++ b/src/v_palette.h @@ -71,6 +71,7 @@ struct FDynamicColormap void ChangeColor (PalEntry lightcolor, int desaturate); void ChangeColorFade (PalEntry lightcolor, PalEntry fadecolor); void BuildLights (); + static void RebuildAllLights(); BYTE *Maps; PalEntry Color; diff --git a/src/v_video.cpp b/src/v_video.cpp index adeb885c4..199310c30 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -328,6 +328,11 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) } } +bool DCanvas::UsesColormap() const +{ + return true; +} + int V_GetColorFromString (const DWORD *palette, const char *cstr) { int c[3], i, p; diff --git a/src/v_video.h b/src/v_video.h index 3a1eca7df..302ba4f5c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -179,6 +179,9 @@ public: // Calculate gamma table void CalcGamma (float gamma, BYTE gammalookup[256]); + // Can be overridden so that the colormaps for sector color/fade won't be built. + virtual bool UsesColormap() const; + // Text drawing functions ----------------------------------------------- virtual void SetFont (FFont *font);