From 0c93f0d1f2dac6ed6914f5e14af581be9cc1b29c Mon Sep 17 00:00:00 2001 From: Joseph Carter Date: Thu, 18 May 2000 04:34:26 +0000 Subject: [PATCH] Skybox support - just add env/*.tga! Bring your own Cmd_LoadSky_f (), I haven't done that or the server code yet. --- include/glquake.h | 3 ++ source/cl_main.c | 2 - source/gl_rmisc.c | 4 +- source/gl_rsurf.c | 10 ++-- source/gl_warp.c | 134 ++++++++++++++++++++-------------------------- 5 files changed, 66 insertions(+), 87 deletions(-) diff --git a/include/glquake.h b/include/glquake.h index a848077..b7e89f7 100644 --- a/include/glquake.h +++ b/include/glquake.h @@ -292,6 +292,9 @@ void EmitBothSkyLayers (msurface_t *fa); void EmitWaterPolys (msurface_t *fa); void EmitSkyPolys (msurface_t *fa); void R_DrawSkyChain (msurface_t *s); +void R_LoadSkys (char *); +void R_ClearSkyBox (void); +void R_DrawSkyBox (void); // // gl_draw.c diff --git a/source/cl_main.c b/source/cl_main.c index 3d2cbc0..c64cd3b 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -1624,8 +1624,6 @@ Host_Init void Host_Init (quakeparms_t *parms) { COM_InitArgv (parms->argc, parms->argv); - COM_AddParm ("-game"); - COM_AddParm ("qw"); Sys_mkdir("qw"); diff --git a/source/gl_rmisc.c b/source/gl_rmisc.c index 1cd8a90..86641e6 100644 --- a/source/gl_rmisc.c +++ b/source/gl_rmisc.c @@ -518,9 +518,7 @@ void R_NewMap (void) mirrortexturenum = i; cl.worldmodel->textures[i]->texturechain = NULL; } -#ifdef QUAKE2 - R_LoadSkys (); -#endif + R_LoadSkys ("none"); } diff --git a/source/gl_rsurf.c b/source/gl_rsurf.c index aa8377e..2bc1f5b 100644 --- a/source/gl_rsurf.c +++ b/source/gl_rsurf.c @@ -1412,9 +1412,8 @@ void R_DrawWorld (void) glColor3f (1,1,1); memset (lightmap_polys, 0, sizeof(lightmap_polys)); -#ifdef QUAKE2 + // Be sure to clear the skybox --KB R_ClearSkyBox (); -#endif R_RecursiveWorldNode (cl.worldmodel->nodes); @@ -1422,9 +1421,8 @@ void R_DrawWorld (void) R_BlendLightmaps (); -#ifdef QUAKE2 + // Draw the skybox --KB R_DrawSkyBox (); -#endif } @@ -1738,10 +1736,10 @@ void GL_BuildLightmaps (void) GL_CreateSurfaceLightmap (m->surfaces + i); if ( m->surfaces[i].flags & SURF_DRAWTURB ) continue; -#ifndef QUAKE2 +//#ifndef QUAKE2 if ( m->surfaces[i].flags & SURF_DRAWSKY ) continue; -#endif +//#endif BuildSurfaceDisplayList (m->surfaces + i); } } diff --git a/source/gl_warp.c b/source/gl_warp.c index 83e7429..71e17ed 100644 --- a/source/gl_warp.c +++ b/source/gl_warp.c @@ -29,8 +29,10 @@ #ifdef HAVE_CONFIG_H # include #endif +#include #include #include +#include #include "bothdefs.h" // needed by: common.h, net.h, client.h @@ -59,9 +61,12 @@ extern model_t *loadmodel; extern int skytexturenum; -int solidskytexture; -int alphaskytexture; -float speedscale; // for top sky and bottom sky +int solidskytexture; +int alphaskytexture; +float speedscale; // for top sky and bottom sky + +// Set to true if a valid skybox is loaded --KB +qboolean skyloaded = false; msurface_t *warpface; @@ -328,39 +333,6 @@ void EmitBothSkyLayers (msurface_t *fa) glDisable (GL_BLEND); } -#ifndef QUAKE2 -/* -================= -R_DrawSkyChain -================= -*/ -void R_DrawSkyChain (msurface_t *s) -{ - msurface_t *fa; - - GL_DisableMultitexture(); - - // used when gl_texsort is on - GL_Bind(solidskytexture); - speedscale = realtime*8; - speedscale -= (int)speedscale & ~127 ; - - for (fa=s ; fa ; fa=fa->texturechain) - EmitSkyPolys (fa); - - glEnable (GL_BLEND); - GL_Bind (alphaskytexture); - speedscale = realtime*16; - speedscale -= (int)speedscale & ~127 ; - - for (fa=s ; fa ; fa=fa->texturechain) - EmitSkyPolys (fa); - - glDisable (GL_BLEND); -} - -#endif - /* ================================================================= @@ -369,9 +341,6 @@ void R_DrawSkyChain (msurface_t *s) ================================================================= */ -#ifdef QUAKE2 - - #define SKY_TEX 2000 /* @@ -382,23 +351,6 @@ void R_DrawSkyChain (msurface_t *s) ================================================================= */ -typedef struct -{ - char manufacturer; - char version; - char encoding; - char bits_per_pixel; - unsigned short xmin,ymin,xmax,ymax; - unsigned short hres,vres; - unsigned char palette[48]; - char reserved; - char color_planes; - unsigned short bytes_per_line; - unsigned short palette_type; - char filler[58]; - unsigned data; // unbounded -} pcx_t; - byte *pcx_rgb; /* @@ -523,6 +475,7 @@ void LoadTGA (FILE *fin) int columns, rows, numPixels; byte *pixbuf; int row, column; + unsigned char red = 0, green = 0, blue = 0, alphabyte = 0; targa_header.id_length = fgetc(fin); targa_header.colormap_type = fgetc(fin); @@ -559,7 +512,6 @@ void LoadTGA (FILE *fin) for(row=rows-1; row>=0; row--) { pixbuf = targa_rgba + row*columns*4; for(column=0; column=0; row--) { pixbuf = targa_rgba + row*columns*4; for(column=0; columntexturechain) + if (skyloaded) { - for (p=fa->polys ; p ; p=p->next) + c_sky = 0; + GL_Bind(solidskytexture); + + // calculate vertex values for sky box + + for (fa=s ; fa ; fa=fa->texturechain) { - for (i=0 ; inumverts ; i++) + for (p=fa->polys ; p ; p=p->next) { - VectorSubtract (p->verts[i], r_origin, verts[i]); + for (i=0 ; inumverts ; i++) + { + VectorSubtract (p->verts[i], r_origin, verts[i]); + } + ClipSkyPolygon (p->numverts, verts[0], 0); } - ClipSkyPolygon (p->numverts, verts[0], 0); } + } else { + GL_DisableMultitexture(); + + // used when gl_texsort is on + GL_Bind(solidskytexture); + speedscale = realtime*8; + speedscale -= (int)speedscale & ~127 ; + + for (fa=s ; fa ; fa=fa->texturechain) + EmitSkyPolys (fa); + + glEnable (GL_BLEND); + GL_Bind (alphaskytexture); + speedscale = realtime*16; + speedscale -= (int)speedscale & ~127 ; + + for (fa=s ; fa ; fa=fa->texturechain) + EmitSkyPolys (fa); + + glDisable (GL_BLEND); } } @@ -1014,9 +1000,7 @@ R_DrawSkyBox int skytexorder[6] = {0,2,1,3,4,5}; void R_DrawSkyBox (void) { - int i, j, k; - vec3_t v; - float s, t; + int i; #if 0 glEnable (GL_BLEND); @@ -1053,8 +1037,6 @@ glEnable (GL_DEPTH_TEST); } -#endif - //=============================================================== /*