Ensure code paths stay within the one renderer.

The gl renderer calling sw functions is bad news. Still all black, but I
think that's because palette setting is disabled.
This commit is contained in:
Bill Currie 2012-04-11 22:45:23 +09:00
parent 898bfa5e5f
commit 525dbcc13e
15 changed files with 197 additions and 51 deletions

View file

@ -158,6 +158,13 @@ typedef struct vid_render_funcs_s {
void (*R_RenderView) (void); void (*R_RenderView) (void);
void (*R_DecayLights) (double frametime); void (*R_DecayLights) (double frametime);
void (*R_ViewChanged) (float aspect);
void (*R_ClearParticles) (void);
void (*R_InitParticles) (void);
void (*SCR_ScreenShot_f) (void);
void (*r_easter_eggs_f) (struct cvar_s *var);
void (*r_particles_style_f) (struct cvar_s *var);
vid_particle_funcs_t *particles; vid_particle_funcs_t *particles;
vid_model_funcs_t *model_funcs; vid_model_funcs_t *model_funcs;
} vid_render_funcs_t; } vid_render_funcs_t;

View file

@ -16,8 +16,10 @@ extern vid_render_funcs_t gl_vid_render_funcs;
extern vid_render_funcs_t glsl_vid_render_funcs; extern vid_render_funcs_t glsl_vid_render_funcs;
extern vid_render_funcs_t sw_vid_render_funcs; extern vid_render_funcs_t sw_vid_render_funcs;
extern vid_render_funcs_t sw32_vid_render_funcs; extern vid_render_funcs_t sw32_vid_render_funcs;
extern vid_render_funcs_t *vid_render_funcs;
#define vr_data vid_render_data #define vr_data vid_render_data
#define vr_funcs vid_render_funcs
extern refdef_t r_refdef; extern refdef_t r_refdef;
extern int r_viewsize; extern int r_viewsize;

View file

@ -1722,9 +1722,43 @@ R_ParticleFunctionInit (void)
gl_r_easter_eggs_f (easter_eggs); gl_r_easter_eggs_f (easter_eggs);
} }
static void
r_particles_nearclip_f (cvar_t *var)
{
Cvar_SetValue (r_particles_nearclip, bound (r_nearclip->value, var->value,
r_farclip->value));
}
static void
r_particles_f (cvar_t *var)
{
R_MaxParticlesCheck (var, r_particles_max);
}
static void
r_particles_max_f (cvar_t *var)
{
R_MaxParticlesCheck (r_particles, var);
}
void void
gl_R_Particles_Init_Cvars (void) gl_R_Particles_Init_Cvars (void)
{ {
easter_eggs = Cvar_Get ("easter_eggs", "0", CVAR_NONE, r_easter_eggs_f,
"Enables easter eggs.");
r_particles = Cvar_Get ("r_particles", "1", CVAR_ARCHIVE, r_particles_f,
"Toggles drawing of particles.");
r_particles_max = Cvar_Get ("r_particles_max", "2048", CVAR_ARCHIVE,
r_particles_max_f, "Maximum amount of "
"particles to display. No maximum, minimum "
"is 0.");
r_particles_nearclip = Cvar_Get ("r_particles_nearclip", "32",
CVAR_ARCHIVE, r_particles_nearclip_f,
"Distance of the particle near clipping "
"plane from the player.");
r_particles_style = Cvar_Get ("r_particles_style", "1", CVAR_ARCHIVE,
r_particles_style_f, "Sets particle style. "
"0 for Id, 1 for QF.");
R_ParticleFunctionInit (); R_ParticleFunctionInit ();
} }

View file

@ -1911,9 +1911,43 @@ R_ParticleFunctionInit (void)
glsl_r_easter_eggs_f (easter_eggs); glsl_r_easter_eggs_f (easter_eggs);
} }
static void
r_particles_nearclip_f (cvar_t *var)
{
Cvar_SetValue (r_particles_nearclip, bound (r_nearclip->value, var->value,
r_farclip->value));
}
static void
r_particles_f (cvar_t *var)
{
R_MaxParticlesCheck (var, r_particles_max);
}
static void
r_particles_max_f (cvar_t *var)
{
R_MaxParticlesCheck (r_particles, var);
}
void void
glsl_R_Particles_Init_Cvars (void) glsl_R_Particles_Init_Cvars (void)
{ {
easter_eggs = Cvar_Get ("easter_eggs", "0", CVAR_NONE, r_easter_eggs_f,
"Enables easter eggs.");
r_particles = Cvar_Get ("r_particles", "1", CVAR_ARCHIVE, r_particles_f,
"Toggles drawing of particles.");
r_particles_max = Cvar_Get ("r_particles_max", "2048", CVAR_ARCHIVE,
r_particles_max_f, "Maximum amount of "
"particles to display. No maximum, minimum "
"is 0.");
r_particles_nearclip = Cvar_Get ("r_particles_nearclip", "32",
CVAR_ARCHIVE, r_particles_nearclip_f,
"Distance of the particle near clipping "
"plane from the player.");
r_particles_style = Cvar_Get ("r_particles_style", "1", CVAR_ARCHIVE,
r_particles_style_f, "Sets particle style. "
"0 for Id, 1 for QF.");
R_ParticleFunctionInit (); R_ParticleFunctionInit ();
} }

View file

@ -117,18 +117,6 @@ crosshaircolor_f (cvar_t *var)
QuatScale (color, 1.0 / 255, crosshair_color); QuatScale (color, 1.0 / 255, crosshair_color);
} }
static void
r_particles_f (cvar_t *var)
{
R_MaxParticlesCheck (var, r_particles_max);
}
static void
r_particles_max_f (cvar_t *var)
{
R_MaxParticlesCheck (r_particles, var);
}
static void static void
r_lightmap_components_f (cvar_t *var) r_lightmap_components_f (cvar_t *var)
{ {
@ -164,13 +152,6 @@ r_nearclip_f (cvar_t *var)
r_farclip->value)); r_farclip->value));
} }
static void
r_particles_nearclip_f (cvar_t *var)
{
Cvar_SetValue (r_particles_nearclip, bound (r_nearclip->value, var->value,
r_farclip->value));
}
static void static void
scr_fisheye_f (cvar_t *var) scr_fisheye_f (cvar_t *var)
{ {
@ -205,9 +186,6 @@ viewsize_f (cvar_t *var)
void void
R_Init_Cvars (void) R_Init_Cvars (void)
{ {
easter_eggs = Cvar_Get ("easter_eggs", "0", CVAR_NONE, r_easter_eggs_f,
"Enables easter eggs.");
cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, NULL, cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, NULL,
"Sets the position of the crosshair on the X-axis."); "Sets the position of the crosshair on the X-axis.");
cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, NULL, cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, NULL,
@ -286,19 +264,6 @@ R_Init_Cvars (void)
r_numsurfs = Cvar_Get ("r_numsurfs", "0", CVAR_NONE, NULL, r_numsurfs = Cvar_Get ("r_numsurfs", "0", CVAR_NONE, NULL,
"Toggles the displaying of number of surfaces " "Toggles the displaying of number of surfaces "
"currently being viewed"); "currently being viewed");
r_particles = Cvar_Get ("r_particles", "1", CVAR_ARCHIVE, r_particles_f,
"Toggles drawing of particles.");
r_particles_max = Cvar_Get ("r_particles_max", "2048", CVAR_ARCHIVE,
r_particles_max_f, "Maximum amount of "
"particles to display. No maximum, minimum "
"is 0.");
r_particles_nearclip = Cvar_Get ("r_particles_nearclip", "32",
CVAR_ARCHIVE, r_particles_nearclip_f,
"Distance of the particle near clipping "
"plane from the player.");
r_particles_style = Cvar_Get ("r_particles_style", "1", CVAR_ARCHIVE,
r_particles_style_f, "Sets particle style. "
"0 for Id, 1 for QF.");
r_reportedgeout = Cvar_Get ("r_reportedgeout", "0", CVAR_NONE, NULL, r_reportedgeout = Cvar_Get ("r_reportedgeout", "0", CVAR_NONE, NULL,
"Toggle the display of how many edges were " "Toggle the display of how many edges were "
"not displayed"); "not displayed");

View file

@ -70,13 +70,13 @@ R_TimeGraph (void)
x = r_refdef.vrect.width - l; x = r_refdef.vrect.width - l;
a = timex - l; a = timex - l;
if (a < 0) { if (a < 0) {
R_LineGraph (x, r_refdef.vrect.height - 2, vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2,
&r_timings[a + MAX_TIMINGS], -a); &r_timings[a + MAX_TIMINGS], -a);
x -= a; x -= a;
l += a; l += a;
a = 0; a = 0;
} }
R_LineGraph (x, r_refdef.vrect.height - 2, &r_timings[a], l); vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, &r_timings[a], l);
timex = (timex + 1) % MAX_TIMINGS; timex = (timex + 1) % MAX_TIMINGS;
} }
@ -95,5 +95,5 @@ R_ZGraph (void)
height[r_framecount & 255] = ((int) r_origin[2]) & 31; height[r_framecount & 255] = ((int) r_origin[2]) & 31;
x = 0; x = 0;
R_LineGraph (x, r_refdef.vrect.height - 2, height, w); vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, height, w);
} }

View file

@ -83,10 +83,10 @@ R_MaxParticlesCheck (cvar_t *r_particles, cvar_t *r_particles_max)
sizeof (particle_t *)); sizeof (particle_t *));
} }
R_ClearParticles (); vr_funcs->R_ClearParticles ();
if (r_init) if (r_init)
R_InitParticles (); vr_funcs->R_InitParticles ();
} }
static int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 }; static int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };

View file

@ -177,7 +177,7 @@ SCR_CalcRefdef (void)
CalcFov (refdef->fov_x, refdef->vrect.width, refdef->vrect.height); CalcFov (refdef->fov_x, refdef->vrect.width, refdef->vrect.height);
// notify the refresh of the change // notify the refresh of the change
R_ViewChanged (vid.aspect); vr_funcs->R_ViewChanged (vid.aspect);
} }
float float
@ -197,6 +197,12 @@ CalcFov (float fov_x, float width, float height)
return a; return a;
} }
static void
ScreenShot_f (void)
{
vr_funcs->SCR_ScreenShot_f ();
}
/* /*
SCR_SizeUp_f SCR_SizeUp_f
@ -232,7 +238,7 @@ SCR_DrawRam (void)
if (!r_cache_thrash) if (!r_cache_thrash)
return; return;
Draw_Pic (scr_vrect.x + 32, scr_vrect.y, scr_ram); vr_funcs->Draw_Pic (scr_vrect.x + 32, scr_vrect.y, scr_ram);
} }
void void
@ -252,7 +258,7 @@ SCR_DrawTurtle (void)
if (count < 3) if (count < 3)
return; return;
Draw_Pic (scr_vrect.x, scr_vrect.y, scr_turtle); vr_funcs->Draw_Pic (scr_vrect.x, scr_vrect.y, scr_turtle);
} }
void void
@ -266,9 +272,9 @@ SCR_DrawPause (void)
if (!vr_data.paused) if (!vr_data.paused)
return; return;
pic = Draw_CachePic ("gfx/pause.lmp", true); pic = vr_funcs->Draw_CachePic ("gfx/pause.lmp", true);
Draw_Pic ((vid.conwidth - pic->width) / 2, vr_funcs->Draw_Pic ((vid.conwidth - pic->width) / 2,
(vid.conheight - 48 - pic->height) / 2, pic); (vid.conheight - 48 - pic->height) / 2, pic);
} }
void void
@ -359,14 +365,14 @@ void
SCR_Init (void) SCR_Init (void)
{ {
// register our commands // register our commands
Cmd_AddCommand ("screenshot", SCR_ScreenShot_f, "Take a screenshot, " Cmd_AddCommand ("screenshot", ScreenShot_f, "Take a screenshot, "
"saves as qfxxx.pcx in the current directory"); "saves as qfxxx.pcx in the current directory");
Cmd_AddCommand ("sizeup", SCR_SizeUp_f, "Increases the screen size"); Cmd_AddCommand ("sizeup", SCR_SizeUp_f, "Increases the screen size");
Cmd_AddCommand ("sizedown", SCR_SizeDown_f, "Decreases the screen size"); Cmd_AddCommand ("sizedown", SCR_SizeDown_f, "Decreases the screen size");
scr_ram = Draw_PicFromWad ("ram"); scr_ram = vr_funcs->Draw_PicFromWad ("ram");
scr_net = Draw_PicFromWad ("net"); scr_net = vr_funcs->Draw_PicFromWad ("net");
scr_turtle = Draw_PicFromWad ("turtle"); scr_turtle = vr_funcs->Draw_PicFromWad ("turtle");
vid = *vr_data.vid; // cache vid = *vr_data.vid; // cache
scr_initialized = true; scr_initialized = true;

View file

@ -832,9 +832,43 @@ R_ParticleFunctionInit (void)
sw_vid_render_funcs.particles = &particles_QF; sw_vid_render_funcs.particles = &particles_QF;
} }
static void
r_particles_nearclip_f (cvar_t *var)
{
Cvar_SetValue (r_particles_nearclip, bound (r_nearclip->value, var->value,
r_farclip->value));
}
static void
r_particles_f (cvar_t *var)
{
R_MaxParticlesCheck (var, r_particles_max);
}
static void
r_particles_max_f (cvar_t *var)
{
R_MaxParticlesCheck (r_particles, var);
}
void void
R_Particles_Init_Cvars (void) R_Particles_Init_Cvars (void)
{ {
easter_eggs = Cvar_Get ("easter_eggs", "0", CVAR_NONE, r_easter_eggs_f,
"Enables easter eggs.");
r_particles = Cvar_Get ("r_particles", "1", CVAR_ARCHIVE, r_particles_f,
"Toggles drawing of particles.");
r_particles_max = Cvar_Get ("r_particles_max", "2048", CVAR_ARCHIVE,
r_particles_max_f, "Maximum amount of "
"particles to display. No maximum, minimum "
"is 0.");
r_particles_nearclip = Cvar_Get ("r_particles_nearclip", "32",
CVAR_ARCHIVE, r_particles_nearclip_f,
"Distance of the particle near clipping "
"plane from the player.");
r_particles_style = Cvar_Get ("r_particles_style", "1", CVAR_ARCHIVE,
r_particles_style_f, "Sets particle style. "
"0 for Id, 1 for QF.");
R_ParticleFunctionInit (); R_ParticleFunctionInit ();
} }

View file

@ -843,9 +843,43 @@ R_ParticleFunctionInit (void)
sw32_vid_render_funcs.particles = &particles_QF; sw32_vid_render_funcs.particles = &particles_QF;
} }
static void
r_particles_nearclip_f (cvar_t *var)
{
Cvar_SetValue (r_particles_nearclip, bound (r_nearclip->value, var->value,
r_farclip->value));
}
static void
r_particles_f (cvar_t *var)
{
R_MaxParticlesCheck (var, r_particles_max);
}
static void
r_particles_max_f (cvar_t *var)
{
R_MaxParticlesCheck (r_particles, var);
}
void void
sw32_R_Particles_Init_Cvars (void) sw32_R_Particles_Init_Cvars (void)
{ {
easter_eggs = Cvar_Get ("easter_eggs", "0", CVAR_NONE, r_easter_eggs_f,
"Enables easter eggs.");
r_particles = Cvar_Get ("r_particles", "1", CVAR_ARCHIVE, r_particles_f,
"Toggles drawing of particles.");
r_particles_max = Cvar_Get ("r_particles_max", "2048", CVAR_ARCHIVE,
r_particles_max_f, "Maximum amount of "
"particles to display. No maximum, minimum "
"is 0.");
r_particles_nearclip = Cvar_Get ("r_particles_nearclip", "32",
CVAR_ARCHIVE, r_particles_nearclip_f,
"Distance of the particle near clipping "
"plane from the player.");
r_particles_style = Cvar_Get ("r_particles_style", "1", CVAR_ARCHIVE,
r_particles_style_f, "Sets particle style. "
"0 for Id, 1 for QF.");
R_ParticleFunctionInit (); R_ParticleFunctionInit ();
} }

View file

@ -48,3 +48,5 @@ vid_render_data_t vid_render_data = {
0, 0,
r_origin, vpn, vright, vup r_origin, vpn, vright, vup
}; };
vid_render_funcs_t *vid_render_funcs;

View file

@ -111,6 +111,12 @@ vid_render_funcs_t gl_vid_render_funcs = {
R_AllocEntity, R_AllocEntity,
gl_R_RenderView, gl_R_RenderView,
R_DecayLights, R_DecayLights,
gl_R_ViewChanged,
gl_R_ClearParticles,
gl_R_InitParticles,
gl_SCR_ScreenShot_f,
gl_r_easter_eggs_f,
gl_r_particles_style_f,
0, 0,
&model_funcs &model_funcs
}; };
@ -120,6 +126,7 @@ gl_vid_render_init (void)
{ {
vr_data.vid->init_gl = GL_Init_Common; vr_data.vid->init_gl = GL_Init_Common;
vr_data.vid->load_gl (); vr_data.vid->load_gl ();
vr_funcs = &gl_vid_render_funcs;
m_funcs = &model_funcs; m_funcs = &model_funcs;
vid = *vr_data.vid; vid = *vr_data.vid;
} }

View file

@ -109,6 +109,12 @@ vid_render_funcs_t glsl_vid_render_funcs = {
R_AllocEntity, R_AllocEntity,
glsl_R_RenderView, glsl_R_RenderView,
R_DecayLights, R_DecayLights,
glsl_R_ViewChanged,
glsl_R_ClearParticles,
glsl_R_InitParticles,
glsl_SCR_ScreenShot_f,
glsl_r_easter_eggs_f,
glsl_r_particles_style_f,
0, 0,
&model_funcs &model_funcs
}; };
@ -116,6 +122,7 @@ vid_render_funcs_t glsl_vid_render_funcs = {
static void static void
glsl_vid_render_init (void) glsl_vid_render_init (void)
{ {
vr_funcs = &glsl_vid_render_funcs;
m_funcs = &model_funcs; m_funcs = &model_funcs;
vid = *vr_data.vid; vid = *vr_data.vid;
} }

View file

@ -104,6 +104,12 @@ vid_render_funcs_t sw_vid_render_funcs = {
R_AllocEntity, R_AllocEntity,
R_RenderView, R_RenderView,
R_DecayLights, R_DecayLights,
R_ViewChanged,
R_ClearParticles,
R_InitParticles,
SCR_ScreenShot_f,
r_easter_eggs_f,
r_particles_style_f,
0, 0,
&model_funcs &model_funcs
}; };
@ -111,6 +117,7 @@ vid_render_funcs_t sw_vid_render_funcs = {
static void static void
sw_vid_render_init (void) sw_vid_render_init (void)
{ {
vr_funcs = &sw_vid_render_funcs;
m_funcs = &model_funcs; m_funcs = &model_funcs;
vid = *vr_data.vid; vid = *vr_data.vid;
} }

View file

@ -109,6 +109,12 @@ vid_render_funcs_t sw32_vid_render_funcs = {
R_AllocEntity, R_AllocEntity,
sw32_R_RenderView, sw32_R_RenderView,
R_DecayLights, R_DecayLights,
sw32_R_ViewChanged,
sw32_R_ClearParticles,
sw32_R_InitParticles,
sw32_SCR_ScreenShot_f,
sw32_r_easter_eggs_f,
sw32_r_particles_style_f,
0, 0,
&model_funcs &model_funcs
}; };
@ -116,6 +122,7 @@ vid_render_funcs_t sw32_vid_render_funcs = {
static void static void
sw32_vid_render_init (void) sw32_vid_render_init (void)
{ {
vr_funcs = &sw32_vid_render_funcs;
m_funcs = &model_funcs; m_funcs = &model_funcs;
vid = *vr_data.vid; vid = *vr_data.vid;
} }