Connect up viddef properly.

Or mostly so, anyway. sw32 is actually putting stuff on the screen.
This commit is contained in:
Bill Currie 2012-02-26 14:00:15 +09:00
parent 4d9c3408a1
commit 6ea4e6617a
17 changed files with 32 additions and 24 deletions

View file

@ -12,7 +12,7 @@ extern unsigned short sw32_8to16table[256];
void VID_GetWindowSize (int def_w, int def_h);
void VID_SetPalette (unsigned char *palette);
void VID_SetPalette (const byte *palette);
void VID_InitGamma (unsigned char *);
qboolean VID_SetGamma (double);
void VID_UpdateGamma (struct cvar_s *);

View file

@ -72,7 +72,7 @@ QFGL_ProcAddress (void *handle, const char *name, qboolean crit)
Sys_MaskPrintf (SYS_VID, "DEBUG: Finding symbol %s ... ", name);
glfunc = vid.get_proc_address (handle, name);
glfunc = vr_data.vid->get_proc_address (handle, name);
if (glfunc) {
Sys_MaskPrintf (SYS_VID, "found [%p]\n", glfunc);
return glfunc;
@ -105,7 +105,7 @@ static void *libgl_handle;
qboolean
GLF_Init (void)
{
libgl_handle = vid.load_library ();
libgl_handle = vr_data.vid->load_library ();
return true;
}

View file

@ -613,7 +613,7 @@ Tdfx_Init8bitPalette (void)
// Check for 8bit Extensions and initialize them.
int i;
if (vid.is8bit)
if (vr_data.vid->is8bit)
return;
if (QFGL_ExtensionPresent ("3DFX_set_global_palette")) {
@ -639,7 +639,7 @@ Tdfx_Init8bitPalette (void)
}
qfglEnable (GL_SHARED_TEXTURE_PALETTE_EXT);
qgl3DfxSetPaletteEXT ((GLuint *) table);
vid.is8bit = true;
vr_data.vid->is8bit = true;
} else {
Sys_MaskPrintf (SYS_VID, "\n 3DFX_set_global_palette not found.");
}
@ -661,7 +661,7 @@ Shared_Init8bitPalette (void)
GLubyte thePalette[256 * 3];
GLubyte *oldPalette, *newPalette;
if (vid.is8bit)
if (vr_data.vid->is8bit)
return;
if (QFGL_ExtensionPresent ("GL_EXT_shared_texture_palette")) {
@ -683,7 +683,7 @@ Shared_Init8bitPalette (void)
}
qglColorTableEXT (GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB,
GL_UNSIGNED_BYTE, (GLvoid *) thePalette);
vid.is8bit = true;
vr_data.vid->is8bit = true;
} else {
Sys_MaskPrintf (SYS_VID,
"\n GL_EXT_shared_texture_palette not found.");
@ -697,7 +697,7 @@ VID_Init8bitPalette (void)
if (vid_use8bit->int_val) {
Tdfx_Init8bitPalette ();
Shared_Init8bitPalette ();
if (!vid.is8bit)
if (!vr_data.vid->is8bit)
Sys_MaskPrintf (SYS_VID, "\n 8-bit extension not found.\n");
} else {
Sys_MaskPrintf (SYS_VID, "disabled.\n");

View file

@ -72,7 +72,7 @@ QFEGL_ProcAddress (void *handle, const char *name, qboolean crit)
Sys_MaskPrintf (SYS_VID, "DEBUG: Finding symbol %s ... ", name);
glfunc = vid.get_proc_address (handle, name);
glfunc = vr_data.vid->get_proc_address (handle, name);
if (glfunc) {
Sys_MaskPrintf (SYS_VID, "found [%p]\n", glfunc);
return glfunc;
@ -105,7 +105,7 @@ static void *libgl_handle;
qboolean
EGLF_Init (void)
{
libgl_handle = vid.load_library ();
libgl_handle = vr_data.vid->load_library ();
return true;
}

View file

@ -96,7 +96,8 @@ VID_SetPalette (unsigned char *palette)
Sys_MaskPrintf (SYS_VID, "Converting palette/colormap to RGBA textures\n");
pal = malloc (256 * VID_GRADES * 4);
for (i = 0, col = vid.colormap8, op = pal; i < 256 * VID_GRADES; i++) {
for (i = 0, col = vr_data.vid->colormap8, op = pal; i < 256 * VID_GRADES;
i++) {
ip = palette + *col++ * 3;
*op++ = *ip++;
*op++ = *ip++;

View file

@ -78,6 +78,7 @@ R_Init (void)
r_funcs = vidrendmodule->functions->vid_render;
mod_funcs = r_funcs->model_funcs;
r_data = vidrendmodule->data->vid_render;
r_data->vid = &viddef;
vidrendmodule->functions->general->p_Init ();
}

View file

@ -368,5 +368,6 @@ SCR_Init (void)
scr_net = Draw_PicFromWad ("net");
scr_turtle = Draw_PicFromWad ("turtle");
vid = *vr_data.vid; // cache
scr_initialized = true;
}

View file

@ -59,9 +59,9 @@ D_Init (void)
r_worldpolysbacktofront = false;
r_recursiveaffinetriangles = true;
vid.surf_cache_size = D_SurfaceCacheForRes;
vid.flush_caches = D_FlushCaches;
vid.init_caches = D_InitCaches;
vr_data.vid->surf_cache_size = D_SurfaceCacheForRes;
vr_data.vid->flush_caches = D_FlushCaches;
vr_data.vid->init_caches = D_InitCaches;
VID_InitBuffers ();
}

View file

@ -68,9 +68,9 @@ sw32_D_Init (void)
sw32_d_zitable[i] = (65536.0 * 65536.0 / (double) i);
}
vid.surf_cache_size = sw32_D_SurfaceCacheForRes;
vid.flush_caches = sw32_D_FlushCaches;
vid.init_caches = sw32_D_InitCaches;
vr_data.vid->surf_cache_size = sw32_D_SurfaceCacheForRes;
vr_data.vid->flush_caches = sw32_D_FlushCaches;
vr_data.vid->init_caches = sw32_D_InitCaches;
VID_InitBuffers ();
}

View file

@ -118,6 +118,7 @@ gl_vid_render_init (void)
m_funcs = &model_funcs;
R_Init_Cvars ();
gl_R_Init ();
vid = *vr_data.vid;
}
static void

View file

@ -118,6 +118,7 @@ glsl_vid_render_init (void)
m_funcs = &model_funcs;
R_Init_Cvars ();
glsl_R_Init ();
vid = *vr_data.vid;
}
static void

View file

@ -113,6 +113,7 @@ sw_vid_render_init (void)
m_funcs = &model_funcs;
R_Init_Cvars ();
sw_R_Init ();
vid = *vr_data.vid;
}
static void

View file

@ -118,6 +118,7 @@ sw32_vid_render_init (void)
m_funcs = &model_funcs;
R_Init_Cvars ();
sw32_R_Init ();
vid = *vr_data.vid;
}
static void

View file

@ -50,7 +50,6 @@ static __attribute__ ((used)) const char rcsid[] =
#include "vid_internal.h"
/* Software and hardware gamma support */
VISIBLE byte gammatable[256];
viddef_t viddef;
byte *vid_colormap;
cvar_t *vid_gamma;
@ -181,7 +180,7 @@ VID_BuildGammaTable (double gamma)
if (gamma == 1.0) { // linear, don't bother with the math
for (i = 0; i < 256; i++) {
gammatable[i] = i;
viddef.gammatable[i] = i;
}
} else {
double g = 1.0 / gamma;
@ -189,7 +188,7 @@ VID_BuildGammaTable (double gamma)
for (i = 0; i < 256; i++) { // Build/update gamma lookup table
v = (int) ((255.0 * pow ((double) i / 255.0, g)) + 0.5);
gammatable[i] = bound (0, v, 255);
viddef.gammatable[i] = bound (0, v, 255);
}
}
}
@ -217,7 +216,7 @@ VID_UpdateGamma (cvar_t *vid_gamma)
Sys_MaskPrintf (SYS_VID, "Setting software gamma to %g\n", gamma);
VID_BuildGammaTable (gamma);
for (i = 0; i < 256 * 3; i++)
viddef.palette[i] = gammatable[viddef.basepal[i]];
viddef.palette[i] = viddef.gammatable[viddef.basepal[i]];
VID_SetPalette (viddef.palette); // update with the new palette
}
}
@ -233,6 +232,8 @@ VID_InitGamma (unsigned char *pal)
int i;
double gamma = 1.45;
viddef.set_palette = VID_SetPalette;
viddef.gammatable = malloc (256);
viddef.basepal = pal;
viddef.palette = malloc (256 * 3);
if ((i = COM_CheckParm ("-gamma"))) {

View file

@ -252,7 +252,7 @@ loadpalette (unsigned short *red, unsigned short *green, unsigned short *blue)
}
void
VID_SetPalette (byte * palette)
VID_SetPalette (const byte *palette)
{
static unsigned short tmppalr[256], tmppalg[256], tmppalb[256];
unsigned short i, *tpr, *tpg, *tpb;

View file

@ -67,7 +67,7 @@ SDL_Surface *screen = NULL;
void
VID_SetPalette (unsigned char *palette)
VID_SetPalette (const byte *palette)
{
SDL_Color colors[256];
int i;

View file

@ -528,7 +528,7 @@ VID_Init_Cvars ()
}
void
VID_SetPalette (unsigned char *palette)
VID_SetPalette (const byte *palette)
{
int i;
XColor colors[256];