DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
palette.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PALETTEFEATURE_GLOW   16
 
#define PALETTEFEATURE_PANTS   4
 
#define PALETTEFEATURE_REVERSED   2
 
#define PALETTEFEATURE_SHIRT   8
 
#define PALETTEFEATURE_STANDARD   1
 
#define PALETTEFEATURE_TRANSPARENT   128
 
#define PALETTEFEATURE_ZERO   32
 

Functions

void BuildGammaTable16 (float prescale, float gamma, float scale, float base, float contrastboost, unsigned short *out, int rampsize)
 
void BuildGammaTable8 (float prescale, float gamma, float scale, float base, float contrastboost, unsigned char *out, int rampsize)
 
void Palette_Init (void)
 

Variables

unsigned int palette_bgra_alpha [256]
 
unsigned int palette_bgra_complete [256]
 
unsigned int palette_bgra_embeddedpic [256]
 
unsigned int palette_bgra_font [256]
 
unsigned int palette_bgra_nocolormap [256]
 
unsigned int palette_bgra_nocolormapnofullbrights [256]
 
unsigned int palette_bgra_nofullbrights [256]
 
unsigned int palette_bgra_nofullbrights_transparent [256]
 
unsigned int palette_bgra_onlyfullbrights [256]
 
unsigned int palette_bgra_onlyfullbrights_transparent [256]
 
unsigned int palette_bgra_pantsaswhite [256]
 
unsigned int palette_bgra_shirtaswhite [256]
 
unsigned int palette_bgra_transparent [256]
 
unsigned char palette_featureflags [256]
 
unsigned char palette_rgb [256][3]
 
unsigned char palette_rgb_pantscolormap [16][3]
 
unsigned char palette_rgb_pantsscoreboard [16][3]
 
unsigned char palette_rgb_shirtcolormap [16][3]
 
unsigned char palette_rgb_shirtscoreboard [16][3]
 
unsigned int q2palette_bgra_complete [256]
 

Macro Definition Documentation

◆ PALETTEFEATURE_GLOW

#define PALETTEFEATURE_GLOW   16

Definition at line 9 of file palette.h.

Referenced by Palette_SetupSpecialPalettes(), and R_SkinFrame_LoadInternalQuake().

◆ PALETTEFEATURE_PANTS

#define PALETTEFEATURE_PANTS   4

Definition at line 7 of file palette.h.

Referenced by Palette_SetupSpecialPalettes(), and R_SkinFrame_LoadInternalQuake().

◆ PALETTEFEATURE_REVERSED

#define PALETTEFEATURE_REVERSED   2

Definition at line 6 of file palette.h.

Referenced by Palette_SetupSpecialPalettes().

◆ PALETTEFEATURE_SHIRT

#define PALETTEFEATURE_SHIRT   8

Definition at line 8 of file palette.h.

Referenced by Palette_SetupSpecialPalettes(), and R_SkinFrame_LoadInternalQuake().

◆ PALETTEFEATURE_STANDARD

#define PALETTEFEATURE_STANDARD   1

Definition at line 5 of file palette.h.

Referenced by Palette_SetupSpecialPalettes().

◆ PALETTEFEATURE_TRANSPARENT

#define PALETTEFEATURE_TRANSPARENT   128

Definition at line 11 of file palette.h.

Referenced by Palette_SetupSpecialPalettes().

◆ PALETTEFEATURE_ZERO

#define PALETTEFEATURE_ZERO   32

Definition at line 10 of file palette.h.

Referenced by Palette_SetupSpecialPalettes().

Function Documentation

◆ BuildGammaTable16()

void BuildGammaTable16 ( float prescale,
float gamma,
float scale,
float base,
float contrastboost,
unsigned short * out,
int rampsize )

Definition at line 240 of file palette.c.

241{
242 int i, adjusted;
243 double invgamma;
244 double t;
245
246 invgamma = 1.0 / gamma;
247 prescale /= (double) (rampsize - 1);
248 for (i = 0;i < rampsize;i++)
249 {
250 t = i * prescale;
251 t = contrastboost * t / ((contrastboost - 1) * t + 1);
252 adjusted = (int) (65535.0 * (pow(t, invgamma) * scale + base) + 0.5);
253 out[i] = bound(0, adjusted, 65535);
254 }
255}
float scale
static int(ZEXPORT *qz_inflate)(z_stream *strm
#define bound(min, num, max)
Definition mathlib.h:34
float pow(float a, float b)
int i

References bound, i, int(), pow(), and scale.

Referenced by SCR_ScreenShot(), and VID_BuildGammaTables().

◆ BuildGammaTable8()

void BuildGammaTable8 ( float prescale,
float gamma,
float scale,
float base,
float contrastboost,
unsigned char * out,
int rampsize )

Definition at line 219 of file palette.c.

220{
221 int i, adjusted;
222 double invgamma;
223 double t, d;
224
225 invgamma = 1.0 / gamma;
226 prescale /= (double) (rampsize - 1);
227 for (i = 0;i < rampsize;i++)
228 {
229 t = i * prescale;
230 d = ((contrastboost - 1) * t + 1);
231 if(d == 0)
232 t = 0; // we could just as well assume 1 here, depending on which side of the division by zero we want to be
233 else
234 t = contrastboost * t / d;
235 adjusted = (int) (255.0 * (pow(t, invgamma) * scale + base) + 0.5);
236 out[i] = bound(0, adjusted, 255);
237 }
238}

References bound, i, int(), pow(), and scale.

Referenced by Palette_Load().

◆ Palette_Init()

void Palette_Init ( void )

Definition at line 366 of file palette.c.

367{
370 Palette_Load();
371}
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
cvar_t r_colormap_palette
Definition palette.c:5
static void Palette_Shutdown(void)
Definition palette.c:257
static void Palette_Load(void)
Definition palette.c:265
static void Palette_NewMap(void)
Definition palette.c:261
#define NULL
Definition qtypes.h:12
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
Definition r_modules.c:25

References Cvar_RegisterVariable(), NULL, Palette_Load(), Palette_NewMap(), Palette_Shutdown(), r_colormap_palette, and R_RegisterModule().

Referenced by CL_Init().

Variable Documentation

◆ palette_bgra_alpha

unsigned int palette_bgra_alpha[256]
extern

Definition at line 15 of file palette.c.

Referenced by Palette_SetupSpecialPalettes().

◆ palette_bgra_complete

unsigned int palette_bgra_complete[256]
extern

◆ palette_bgra_embeddedpic

unsigned int palette_bgra_embeddedpic[256]
extern

Definition at line 25 of file palette.c.

Referenced by Image_GetEmbeddedPicBGRA(), Palette_Load(), and R_Shadow_MakeTextures().

◆ palette_bgra_font

unsigned int palette_bgra_font[256]
extern

Definition at line 14 of file palette.c.

Referenced by LoadConChars_BGRA(), and Palette_SetupSpecialPalettes().

◆ palette_bgra_nocolormap

unsigned int palette_bgra_nocolormap[256]
extern

◆ palette_bgra_nocolormapnofullbrights

unsigned int palette_bgra_nocolormapnofullbrights[256]
extern

◆ palette_bgra_nofullbrights

unsigned int palette_bgra_nofullbrights[256]
extern

◆ palette_bgra_nofullbrights_transparent

unsigned int palette_bgra_nofullbrights_transparent[256]
extern

◆ palette_bgra_onlyfullbrights

unsigned int palette_bgra_onlyfullbrights[256]
extern

◆ palette_bgra_onlyfullbrights_transparent

unsigned int palette_bgra_onlyfullbrights_transparent[256]
extern

◆ palette_bgra_pantsaswhite

unsigned int palette_bgra_pantsaswhite[256]
extern

◆ palette_bgra_shirtaswhite

unsigned int palette_bgra_shirtaswhite[256]
extern

◆ palette_bgra_transparent

unsigned int palette_bgra_transparent[256]
extern

◆ palette_featureflags

unsigned char palette_featureflags[256]
extern

Definition at line 26 of file palette.c.

Referenced by Palette_SetupSpecialPalettes(), and R_SkinFrame_LoadInternalQuake().

◆ palette_rgb

unsigned char palette_rgb[256][3]
extern

◆ palette_rgb_pantscolormap

unsigned char palette_rgb_pantscolormap[16][3]
extern

Definition at line 8 of file palette.c.

Referenced by CL_SetEntityColormapColors(), CL_UpdateScreen(), and Palette_Load().

◆ palette_rgb_pantsscoreboard

unsigned char palette_rgb_pantsscoreboard[16][3]
extern

◆ palette_rgb_shirtcolormap

unsigned char palette_rgb_shirtcolormap[16][3]
extern

Definition at line 9 of file palette.c.

Referenced by CL_SetEntityColormapColors(), CL_UpdateScreen(), and Palette_Load().

◆ palette_rgb_shirtscoreboard

unsigned char palette_rgb_shirtscoreboard[16][3]
extern

◆ q2palette_bgra_complete

unsigned int q2palette_bgra_complete[256]
extern

Definition at line 28 of file palette.c.

Referenced by LoadWAL_BGRA(), and Palette_LoadQ2Colormap().