diff --git a/include/r_shared.h b/include/r_shared.h index b1b2a950e..291376f82 100644 --- a/include/r_shared.h +++ b/include/r_shared.h @@ -139,6 +139,9 @@ extern void SetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv, extern int r_skymade; extern void R_MakeSky (void); +extern int solidskytexture; +extern int alphaskytexture; + extern int ubasestep, errorterm, erroradjustup, erroradjustdown; extern double r_realtime; diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index 5a41c8f5d..450220e2a 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -335,10 +335,6 @@ R_TextureAnimation (texture_t *base) /* BRUSH MODELS */ -extern float speedscale; // for top sky and bottom sky -extern int solidskytexture; -extern int alphaskytexture; - void GL_UploadLightmap (int i, int x, int y, int w, int h) { diff --git a/libs/video/renderer/gl/gl_sky.c b/libs/video/renderer/gl/gl_sky.c index aaf98fb84..db8c1b562 100644 --- a/libs/video/renderer/gl/gl_sky.c +++ b/libs/video/renderer/gl/gl_sky.c @@ -55,7 +55,6 @@ #include "r_cvar.h" char *suf[6] = { "rt", "bk", "lf", "ft", "up", "dn" }; -float speedscale; // for top sky and bottom sky int solidskytexture; int alphaskytexture; @@ -230,6 +229,8 @@ R_DrawSkyLayer (float s) void R_DrawSkyDome (void) { + float speedscale; // for top sky and bottom sky + qfglDisable (GL_DEPTH_TEST); qfglDepthRange (gldepthmax, gldepthmax); diff --git a/libs/video/renderer/gl/gl_sky_clip.c b/libs/video/renderer/gl/gl_sky_clip.c index 873806ccf..b5bd5b875 100644 --- a/libs/video/renderer/gl/gl_sky_clip.c +++ b/libs/video/renderer/gl/gl_sky_clip.c @@ -658,6 +658,38 @@ R_DrawSkyDomePoly (glpoly_t *poly) qfglEnd (); } +void +EmitSkyPolys (float speedscale, msurface_t *fa) +{ + glpoly_t *p; + float *v; + int i; + float s, t; + vec3_t dir; + float length; + + for (p = fa->polys; p; p = p->next) { + qfglBegin (GL_POLYGON); + for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE) { + VectorSubtract (v, r_origin, dir); + dir[2] *= 3; // flatten the sphere + + length = DotProduct (dir, dir); + length = 6 * 63 / sqrt (length); + + dir[0] *= length; + dir[1] *= length; + + s = (speedscale + dir[0]) * (1.0/128); + t = (speedscale + dir[1]) * (1.0/128); + + qfglTexCoord2f (s, t); + qfglVertex3fv (v); + } + qfglEnd (); + } +} + void R_DrawSkyChain (msurface_t *sky_chain) { @@ -694,6 +726,30 @@ R_DrawSkyChain (msurface_t *sky_chain) sc = sc->texturechain; } qfglDepthRange (gldepthmin, gldepthmax); + } else if (gl_sky_clip->int_val == 2) { + float speedscale; + + speedscale = r_realtime*8; + speedscale -= (int)speedscale & ~127 ; + + qfglBindTexture (GL_TEXTURE_2D, solidskytexture); + while (sc) { + EmitSkyPolys (speedscale, sc); + sc = sc->texturechain; + } + + if (gl_skymultipass->int_val) { + sc = sky_chain; + + speedscale = r_realtime*16; + speedscale -= (int)speedscale & ~127 ; + + qfglBindTexture (GL_TEXTURE_2D, alphaskytexture); + while (sc) { + EmitSkyPolys (speedscale, sc); + sc = sc->texturechain; + } + } } else { // this code is duplicated from above because skydome is not yet // clipped