mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-01 17:12:15 +00:00
[vid] Add a function to set the palette and colormap
Mostly for qwaq as it uses the default VGA palette but I need to do some testing with the quake palette.
This commit is contained in:
parent
7c53a68ad7
commit
8fa6167a57
6 changed files with 57 additions and 16 deletions
|
@ -71,6 +71,7 @@ void VID_Init_Cvars (void);
|
||||||
// the palette data will go away after the call, so it must be copied off if
|
// the palette data will go away after the call, so it must be copied off if
|
||||||
// the video driver will need it again
|
// the video driver will need it again
|
||||||
void VID_Init (byte *palette, byte *colormap);
|
void VID_Init (byte *palette, byte *colormap);
|
||||||
|
void VID_SetPalette (byte *palette, byte *colormap);
|
||||||
void VID_SetCaption (const char *text);
|
void VID_SetCaption (const char *text);
|
||||||
void VID_ClearMemory (void);
|
void VID_ClearMemory (void);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
typedef struct vid_system_s {
|
typedef struct vid_system_s {
|
||||||
void (*init) (byte *palette, byte *colormap);
|
void (*init) (byte *palette, byte *colormap);
|
||||||
|
void (*set_palette) (byte *palette, byte *colormap);
|
||||||
void (*init_cvars) (void);
|
void (*init_cvars) (void);
|
||||||
void (*update_fullscreen) (int fullscreen);
|
void (*update_fullscreen) (int fullscreen);
|
||||||
} vid_system_t;
|
} vid_system_t;
|
||||||
|
|
|
@ -246,7 +246,11 @@ VID_InitGamma (const byte *pal)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double gamma = 1.0;
|
double gamma = 1.0;
|
||||||
|
static int cvar_initialized;
|
||||||
|
|
||||||
|
free (viddef.gammatable);
|
||||||
|
free (viddef.palette);
|
||||||
|
free (viddef.palette32);
|
||||||
viddef.gammatable = malloc (256);
|
viddef.gammatable = malloc (256);
|
||||||
viddef.basepal = pal;
|
viddef.basepal = pal;
|
||||||
viddef.palette = malloc (256 * 3);
|
viddef.palette = malloc (256 * 3);
|
||||||
|
@ -256,9 +260,13 @@ VID_InitGamma (const byte *pal)
|
||||||
}
|
}
|
||||||
gamma = bound (0.1, gamma, 9.9);
|
gamma = bound (0.1, gamma, 9.9);
|
||||||
|
|
||||||
Cvar_Register (&vid_gamma_cvar, vid_gamma_f, 0);
|
if (!cvar_initialized) {
|
||||||
|
cvar_initialized = 1;
|
||||||
|
Cvar_Register (&vid_gamma_cvar, vid_gamma_f, 0);
|
||||||
|
}
|
||||||
|
|
||||||
VID_BuildGammaTable (vid_gamma);
|
//VID_BuildGammaTable (vid_gamma);
|
||||||
|
VID_UpdateGamma ();
|
||||||
|
|
||||||
if (viddef.onPaletteChanged) {
|
if (viddef.onPaletteChanged) {
|
||||||
LISTENER_INVOKE (viddef.onPaletteChanged, &viddef);
|
LISTENER_INVOKE (viddef.onPaletteChanged, &viddef);
|
||||||
|
@ -315,6 +323,12 @@ VID_Init (byte *palette, byte *colormap)
|
||||||
vid_system.init (palette, colormap);
|
vid_system.init (palette, colormap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
VID_SetPalette (byte *palette, byte *colormap)
|
||||||
|
{
|
||||||
|
vid_system.set_palette (palette, colormap);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vid_fullscreen_f (void *data, const cvar_t *var)
|
vid_fullscreen_f (void *data, const cvar_t *var)
|
||||||
{
|
{
|
||||||
|
|
|
@ -117,6 +117,19 @@ VID_shutdown (void *data)
|
||||||
Win_CloseDisplay ();
|
Win_CloseDisplay ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static v oid
|
||||||
|
Win_VID_SetPalette (byte *palette, byte *colormap)
|
||||||
|
{
|
||||||
|
viddef.colormap8 = colormap;
|
||||||
|
viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES];
|
||||||
|
if (vid_internal.set_colormap) {
|
||||||
|
vid_internal.set_colormap (vid_internal.data, colormap);
|
||||||
|
}
|
||||||
|
|
||||||
|
VID_InitGamma (palette);
|
||||||
|
viddef.vid_internal->set_palette (win_sw_context, palette);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Win_VID_Init (byte *palette, byte *colormap)
|
Win_VID_Init (byte *palette, byte *colormap)
|
||||||
{
|
{
|
||||||
|
@ -131,11 +144,6 @@ Win_VID_Init (byte *palette, byte *colormap)
|
||||||
R_LoadModule (&vid_internal);
|
R_LoadModule (&vid_internal);
|
||||||
|
|
||||||
viddef.numpages = 1;
|
viddef.numpages = 1;
|
||||||
viddef.colormap8 = colormap;
|
|
||||||
viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES];
|
|
||||||
if (vid_internal.set_colormap) {
|
|
||||||
vid_internal.set_colormap (vid_internal.data, colormap);
|
|
||||||
}
|
|
||||||
|
|
||||||
VID_GetWindowSize (640, 480);
|
VID_GetWindowSize (640, 480);
|
||||||
Win_OpenDisplay ();
|
Win_OpenDisplay ();
|
||||||
|
@ -144,8 +152,7 @@ Win_VID_Init (byte *palette, byte *colormap)
|
||||||
Win_CreateWindow (viddef.width, viddef.height);
|
Win_CreateWindow (viddef.width, viddef.height);
|
||||||
vid_internal.create_context (win_sw_context);
|
vid_internal.create_context (win_sw_context);
|
||||||
|
|
||||||
VID_InitGamma (palette);
|
Win_VID_SetPalette (palette, colormap);
|
||||||
viddef.vid_internal->set_palette (win_sw_context, palette);
|
|
||||||
|
|
||||||
Sys_MaskPrintf (SYS_vid, "Video mode %dx%d initialized.\n",
|
Sys_MaskPrintf (SYS_vid, "Video mode %dx%d initialized.\n",
|
||||||
viddef.width, viddef.height);
|
viddef.width, viddef.height);
|
||||||
|
@ -166,6 +173,7 @@ Win_VID_Init_Cvars (void)
|
||||||
|
|
||||||
vid_system_t vid_system = {
|
vid_system_t vid_system = {
|
||||||
.init = Win_VID_Init,
|
.init = Win_VID_Init,
|
||||||
|
.set_palette = Win_VID_SetPalette,
|
||||||
.init_cvars = Win_VID_Init_Cvars,
|
.init_cvars = Win_VID_Init_Cvars,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,19 @@ VID_shutdown (void *data)
|
||||||
X11_CloseDisplay ();
|
X11_CloseDisplay ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
X11_VID_SetPalette (byte *palette, byte *colormap)
|
||||||
|
{
|
||||||
|
viddef.colormap8 = colormap;
|
||||||
|
viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES];
|
||||||
|
if (vid_internal.set_colormap) {
|
||||||
|
vid_internal.set_colormap (vid_internal.data, colormap);
|
||||||
|
}
|
||||||
|
|
||||||
|
VID_InitGamma (palette);
|
||||||
|
vid_internal.set_palette (vid_internal.data, viddef.palette);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set up color translation tables and the window. Takes a 256-color 8-bit
|
Set up color translation tables and the window. Takes a 256-color 8-bit
|
||||||
palette. Palette data will go away after the call, so copy it if you'll
|
palette. Palette data will go away after the call, so copy it if you'll
|
||||||
|
@ -108,11 +121,6 @@ X11_VID_Init (byte *palette, byte *colormap)
|
||||||
R_LoadModule (&vid_internal);
|
R_LoadModule (&vid_internal);
|
||||||
|
|
||||||
viddef.numpages = 2;
|
viddef.numpages = 2;
|
||||||
viddef.colormap8 = colormap;
|
|
||||||
viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES];
|
|
||||||
if (vid_internal.set_colormap) {
|
|
||||||
vid_internal.set_colormap (vid_internal.data, colormap);
|
|
||||||
}
|
|
||||||
|
|
||||||
srandom (getpid ());
|
srandom (getpid ());
|
||||||
|
|
||||||
|
@ -124,8 +132,7 @@ X11_VID_Init (byte *palette, byte *colormap)
|
||||||
X11_CreateNullCursor (); // hide mouse pointer
|
X11_CreateNullCursor (); // hide mouse pointer
|
||||||
vid_internal.create_context (vid_internal.data);
|
vid_internal.create_context (vid_internal.data);
|
||||||
|
|
||||||
VID_InitGamma (palette);
|
X11_VID_SetPalette (palette, colormap);
|
||||||
vid_internal.set_palette (vid_internal.data, viddef.palette);
|
|
||||||
|
|
||||||
Sys_MaskPrintf (SYS_vid, "Video mode %dx%d initialized.\n",
|
Sys_MaskPrintf (SYS_vid, "Video mode %dx%d initialized.\n",
|
||||||
viddef.width, viddef.height);
|
viddef.width, viddef.height);
|
||||||
|
@ -149,6 +156,7 @@ vid_system_t vid_system = {
|
||||||
.init = X11_VID_Init,
|
.init = X11_VID_Init,
|
||||||
.init_cvars = X11_VID_Init_Cvars,
|
.init_cvars = X11_VID_Init_Cvars,
|
||||||
.update_fullscreen = X11_UpdateFullscreen,
|
.update_fullscreen = X11_UpdateFullscreen,
|
||||||
|
.set_palette = X11_VID_SetPalette,
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -124,6 +124,14 @@ bi_refresh_2d (progs_t *pr, void *_res)
|
||||||
qc2d = P_FUNCTION (pr, 0);
|
qc2d = P_FUNCTION (pr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bi_setpalette (progs_t *pr, void *_res)
|
||||||
|
{
|
||||||
|
byte *palette = (byte *) P_GPOINTER (pr, 0);
|
||||||
|
byte *colormap = (byte *) P_GPOINTER (pr, 1);
|
||||||
|
VID_SetPalette (palette, colormap);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bi_shutdown (progs_t *pr, void *_res)
|
bi_shutdown (progs_t *pr, void *_res)
|
||||||
{
|
{
|
||||||
|
@ -136,6 +144,7 @@ static builtin_t builtins[] = {
|
||||||
bi(newscene, -1, 1, p(long)),
|
bi(newscene, -1, 1, p(long)),
|
||||||
bi(refresh, -1, 0),
|
bi(refresh, -1, 0),
|
||||||
bi(refresh_2d, -1, 1, p(func)),
|
bi(refresh_2d, -1, 1, p(func)),
|
||||||
|
bi(setpalette, -1, 2, p(ptr), p(ptr)),
|
||||||
bi(shutdown, -1, 0),
|
bi(shutdown, -1, 0),
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue