From 08a213cdc30af6dfdf3eb2ea5b08481fcccf924d Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 23 Aug 2004 02:10:27 +0000 Subject: [PATCH] merged R_Shadow_Stage_LightWithShadows and R_Shadow_Stage_LightWithoutShadows to make a R_Shadow_Stage_Light which takes a shadowtest parameter, just a bit of code reduction git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4361 d7cf8633-e32d-0410-b094-e92efae38249 --- r_shadow.c | 36 ++++++------------------------------ r_shadow.h | 6 ------ 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/r_shadow.c b/r_shadow.c index a209709e..82d18025 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -908,7 +908,7 @@ void R_Shadow_Stage_ShadowVolumes(void) // optimize for them as noted above } -void R_Shadow_Stage_LightWithoutShadows(void) +void R_Shadow_Stage_Light(int shadowtest) { rmeshstate_t m; memset(&m, 0, sizeof(m)); @@ -923,31 +923,10 @@ void R_Shadow_Stage_LightWithoutShadows(void) qglDepthFunc(GL_EQUAL); qglCullFace(GL_FRONT); // quake is backwards, this culls back faces qglEnable(GL_CULL_FACE); - qglDisable(GL_STENCIL_TEST); - if (gl_support_stenciltwoside) - qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); - qglStencilMask(~0); - qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - qglStencilFunc(GL_EQUAL, 128, ~0); - r_shadowstage = SHADOWSTAGE_LIGHT; - c_rt_lights++; -} - -void R_Shadow_Stage_LightWithShadows(void) -{ - rmeshstate_t m; - memset(&m, 0, sizeof(m)); - R_Mesh_State(&m); - GL_BlendFunc(GL_ONE, GL_ONE); - GL_DepthMask(false); - GL_DepthTest(true); - qglPolygonOffset(0, 0); - //qglDisable(GL_POLYGON_OFFSET_FILL); - GL_Color(1, 1, 1, 1); - GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); - qglDepthFunc(GL_EQUAL); - qglCullFace(GL_FRONT); // quake is backwards, this culls back faces - qglEnable(GL_STENCIL_TEST); + if (shadowtest) + qglDisable(GL_STENCIL_TEST); + else + qglEnable(GL_STENCIL_TEST); if (gl_support_stenciltwoside) qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); qglStencilMask(~0); @@ -2206,10 +2185,7 @@ void R_DrawRTLight(rtlight_t *rtlight, int visiblevolumes) if (!visiblevolumes) { - if (shadow && gl_stencil) - R_Shadow_Stage_LightWithShadows(); - else - R_Shadow_Stage_LightWithoutShadows(); + R_Shadow_Stage_Light(shadow && gl_stencil); ent = &cl_entities[0].render; if (ent->model && ent->model->DrawLight) diff --git a/r_shadow.h b/r_shadow.h index 5f608603..ea8601af 100644 --- a/r_shadow.h +++ b/r_shadow.h @@ -41,12 +41,6 @@ void R_Shadow_RenderLighting(int numverts, int numtriangles, const int *elements void R_Shadow_ClearStencil(void); void R_Shadow_RenderVolume(int numvertices, int numtriangles, const float *vertex3f, const int *element3i); -void R_Shadow_Stage_Begin(void); -void R_Shadow_LoadWorldLightsIfNeeded(void); -void R_Shadow_Stage_ShadowVolumes(void); -void R_Shadow_Stage_LightWithShadows(void); -void R_Shadow_Stage_LightWithoutShadows(void); -void R_Shadow_Stage_End(void); int R_Shadow_ScissorForBBox(const float *mins, const float *maxs); // these never change, they are used to create attenuation matrices -- 2.39.2