diff --git a/source/gl_rmain.c b/source/gl_rmain.c index ecc135e..04aff60 100644 --- a/source/gl_rmain.c +++ b/source/gl_rmain.c @@ -118,6 +118,7 @@ cvar_t *gl_particles; cvar_t *r_skyname; cvar_t *gl_skymultipass; +cvar_t *gl_sky_clip; cvar_t *gl_fb_models; cvar_t *gl_fb_bmodels; diff --git a/source/gl_rmisc.c b/source/gl_rmisc.c index 4dd52d7..c5dd2d7 100644 --- a/source/gl_rmisc.c +++ b/source/gl_rmisc.c @@ -247,8 +247,9 @@ void R_Init_Cvars (void) r_skyname = Cvar_Get("r_skyname", "none", CVAR_NONE, "name of the current skybox"); gl_skymultipass = Cvar_Get("gl_skymultipass", "1", CVAR_NONE, - "controls wether the skydome is single or double pass"); - + "controls whether the skydome is single or double pass"); + gl_sky_clip = Cvar_Get ("gl_sky_clip", "0", CVAR_NONE, + "controls whether sky is drawn first (0) or later (1)"); } /* diff --git a/source/gl_rsurf.c b/source/gl_rsurf.c index 7018590..a45b865 100644 --- a/source/gl_rsurf.c +++ b/source/gl_rsurf.c @@ -65,7 +65,7 @@ int lightmap_textures; unsigned int blocklights[18*18*3]; -cvar_t *gl_colorlights; +cvar_t *gl_colorlights; #define BLOCK_WIDTH 128 #define BLOCK_HEIGHT 128 @@ -91,6 +91,7 @@ int allocated[MAX_LIGHTMAPS][BLOCK_WIDTH]; byte *lightmaps[MAX_LIGHTMAPS]; msurface_t *waterchain = NULL; +msurface_t *sky_chain; extern qboolean lighthalf; @@ -699,8 +700,7 @@ void DrawTextureChains (void) glDisable(GL_BLEND); - for (i=0 ; inumtextures ; i++) - { + for (i=0 ; inumtextures ; i++) { if (!cl.worldmodel->textures[i]) continue; for (s = cl.worldmodel->textures[i]->texturechain;s;s = s->texturechain) @@ -753,10 +753,12 @@ void R_DrawBrushModel (entity_t *e) memset (lightmap_polys, 0, sizeof(lightmap_polys)); memset (fullbright_polys, 0, sizeof(fullbright_polys)); + if (gl_sky_clip->int_val) { + sky_chain = 0; + } VectorSubtract (r_refdef.vieworg, e->origin, modelorg); - if (rotated) - { + if (rotated) { vec3_t temp; vec3_t forward, right, up; @@ -798,10 +800,12 @@ void R_DrawBrushModel (entity_t *e) // // draw texture // - for (i=0 ; inummodelsurfaces ; i++, psurf++) - { - if (psurf->flags & SURF_DRAWSKY) + for (i=0 ; inummodelsurfaces ; i++, psurf++) { + if (psurf->flags & SURF_DRAWSKY) { + psurf->texturechain = sky_chain; + sky_chain = psurf; return; + } // find which side of the node we are on pplane = psurf->plane; @@ -827,6 +831,9 @@ void R_DrawBrushModel (entity_t *e) if (gl_fb_bmodels->int_val) R_RenderFullbrights (); + if (gl_sky_clip->int_val) + R_DrawSkyChain (sky_chain); + glPopMatrix (); } @@ -927,8 +934,11 @@ void R_RecursiveWorldNode (mnode_t *node) if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) continue; // wrong side - if (surf->flags & SURF_DRAWSKY) + if (surf->flags & SURF_DRAWSKY) { + surf->texturechain = sky_chain; + sky_chain = surf; continue; + } if (surf->flags & SURF_DRAWTURB) { @@ -976,8 +986,12 @@ void R_DrawWorld (void) memset (lightmap_polys, 0, sizeof(lightmap_polys)); memset (fullbright_polys, 0, sizeof(fullbright_polys)); - // Be sure to clear the skybox --KB - R_DrawSky (); + if (gl_sky_clip->int_val) { + sky_chain = 0; + } else { + // Be sure to clear the skybox --KB + R_DrawSky (); + } R_RecursiveWorldNode (cl.worldmodel->nodes); @@ -988,6 +1002,9 @@ void R_DrawWorld (void) if (gl_fb_bmodels->int_val) R_RenderFullbrights (); + + if (gl_sky_clip->int_val) + R_DrawSkyChain (sky_chain); } diff --git a/source/gl_sky.c b/source/gl_sky.c index 5f10b9e..4846031 100644 --- a/source/gl_sky.c +++ b/source/gl_sky.c @@ -53,19 +53,13 @@ msurface_t *warpface; /* -================================================================= - - Quake 2 environment sky - -================================================================= + Quake 2 environment sky */ #define SKY_TEX 2000 /* -================== -R_LoadSkys -================== + R_LoadSkys */ char *suf[6] = { "rt", "bk", "lf", "ft", "up", "dn" }; void @@ -274,6 +268,41 @@ R_DrawSky (void) R_DrawSkyDome (); } +void +R_DrawSkyBoxPoly (glpoly_t *poly) +{ + vec3_t verts[32]; + int i; + + if (poly->numverts>=32) { + Con_Printf ("too many verts!"); + abort(); + } + for (i=0; i< poly->numverts; i++) { + VectorSubtract (poly->verts[i], r_refdef.vieworg, verts[i]); + } +} + +void +R_DrawSkyDomePoly (glpoly_t *poly) +{ +} + +void +R_DrawSkyChain (msurface_t *sky_chain) +{ + if (skyloaded) { + while (sky_chain) { + R_DrawSkyBoxPoly (sky_chain->polys); + sky_chain = sky_chain->texturechain; + } + } else { + while (sky_chain) { + R_DrawSkyDomePoly (sky_chain->polys); + sky_chain = sky_chain->texturechain; + } + } +} //=============================================================== diff --git a/source/in_svgalib.c b/source/in_svgalib.c index ea23a46..9ebdc08 100644 --- a/source/in_svgalib.c +++ b/source/in_svgalib.c @@ -29,17 +29,19 @@ $Id$ */ -#include "qtypes.h" -#include "quakedef.h" -#include "keys.h" #include "client.h" -#include "sys.h" +#include "cl_input.h" +#include "cmd.h" #include "console.h" #include "cvar.h" -#include "cmd.h" -#include "qargs.h" #include "input.h" #include "joystick.h" +#include "keys.h" +#include "qargs.h" +#include "qtypes.h" +#include "quakedef.h" +#include "sys.h" +#include "view.h" #include #include diff --git a/source/pr_edict.c b/source/pr_edict.c index 55189c8..c59dba1 100644 --- a/source/pr_edict.c +++ b/source/pr_edict.c @@ -48,6 +48,8 @@ #include #endif +cvar_t *r_skyname; + void SV_Error (char *error, ...); void FindEdictFieldOffsets(); @@ -829,7 +831,6 @@ char *ED_ParseEdict (char *data, edict_t *ent) qboolean anglehack; qboolean init; char keyname[256]; - cvar_t *r_skyname; init = false; diff --git a/source/sv_main.c b/source/sv_main.c index 2319833..be0155a 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -130,6 +130,7 @@ QFile *sv_fraglogfile; void SV_AcceptClient (netadr_t adr, int userid, char *userinfo); void Master_Shutdown (void); +void PR_Init_Cvars (void); //============================================================================