SKYBOXES!

Relevant cvar to change the name of the skybox is r_skyname which defaults
to "sky".  If you don't have the files you'll get an ugly red background
in place of the sky.  I'll fix that shortly.

Sorry software people, this is just the Q2 code I'm turning on which doesn
not work for software.  The code is pretty simple though and most of it's
written already in gl_warp.c---just move that to r_sky and use the pcx's
instead of the tga's..
This commit is contained in:
Joseph Carter 2000-03-02 13:56:01 +00:00
parent 6483ab1ad5
commit 54501eaed7
5 changed files with 65 additions and 72 deletions

View file

@ -1080,6 +1080,11 @@ R_RenderView ( void ) {
glFogi (GL_FOG_MODE, GL_EXP2);
glFogfv (GL_FOG_COLOR, colors);
glFogf (GL_FOG_DENSITY, (GLfloat) r_fog->value);
// glFogi (GL_FOG_MODE, GL_LINEAR);
// glFogfv (GL_FOG_COLOR, colors);
// glFogf (GL_FOG_START, 300.0);
// glFogf (GL_FOG_END, 1500.0);
// glFogf (GL_FOG_DENSITY, 0.2);
glEnable (GL_FOG);
R_RenderScene ();

View file

@ -601,9 +601,7 @@ void R_NewMap (void)
skytexturenum = i;
cl.worldmodel->textures[i]->texturechain = NULL;
}
#ifdef QUAKE2
R_LoadSkys ();
#endif
}

View file

@ -1,4 +1,5 @@
/*
gl_rsurf.c - surrface-related refresh code
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 1999,2000 contributors of the QuakeForge project
Please see the file "AUTHORS" for a list of contributors
@ -19,12 +20,11 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// r_surf.c: surrface-related refresh code
#include "qtypes.h"
#include "quakedef.h"
#include "glquake.h"
#include "mathlib.h"
#include <qtypes.h>
#include <quakedef.h>
#include <glquake.h>
#include <mathlib.h>
#include <sys.h>
int skytexturenum;
@ -1321,9 +1321,7 @@ void R_DrawWorld (void)
glColor3f (1,1,1);
memset (lightmap_polys, 0, sizeof(lightmap_polys));
#ifdef QUAKE2
R_ClearSkyBox ();
#endif
R_RecursiveWorldNode (cl.worldmodel->nodes);
@ -1331,9 +1329,7 @@ void R_DrawWorld (void)
R_BlendLightmaps ();
#ifdef QUAKE2
R_DrawSkyBox ();
#endif
}
@ -1638,10 +1634,8 @@ void GL_BuildLightmaps (void)
GL_CreateSurfaceLightmap (m->surfaces + i);
if ( m->surfaces[i].flags & SURF_DRAWTURB )
continue;
#ifndef QUAKE2
if ( m->surfaces[i].flags & SURF_DRAWSKY )
continue;
#endif
BuildSurfaceDisplayList (m->surfaces + i);
}
}

View file

@ -27,11 +27,12 @@
Boston, MA 02111-1307, USA
*/
#include "qtypes.h"
#include "quakedef.h"
#include "glquake.h"
#include "mathlib.h"
#include <qtypes.h>
#include <quakedef.h>
#include <glquake.h>
#include <mathlib.h>
#include <sys.h>
#include <console.h>
extern model_t *loadmodel;
@ -295,6 +296,7 @@ EmitBothSkyLayers ( msurface_t *fa ) {
glDisable (GL_BLEND);
}
#if 0
/*
R_DrawSkyChain
*/
@ -303,55 +305,19 @@ 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
/*
Quake 2 sky rendering ("skyboxes")
*/
#ifdef QUAKE2
#define SKY_TEX 2000
/*
PCX Loading
*/
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;
/*
@ -462,6 +428,7 @@ LoadTGA (QFile *fin) {
int columns, rows, numPixels;
byte *pixbuf;
int row, column;
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
targa_header.id_length = Qgetc(fin);
targa_header.colormap_type = Qgetc(fin);
@ -498,7 +465,6 @@ LoadTGA (QFile *fin) {
for(row=rows-1; row>=0; row--) {
pixbuf = targa_rgba + row*columns*4;
for(column=0; column<columns; column++) {
unsigned char red,green,blue,alphabyte;
switch (targa_header.pixel_size) {
case 24:
@ -525,7 +491,7 @@ LoadTGA (QFile *fin) {
}
}
else if (targa_header.image_type==10) { // Runlength encoded RGB images
unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
unsigned char packetHeader,packetSize,j;
for(row=rows-1; row>=0; row--) {
pixbuf = targa_rgba + row*columns*4;
for(column=0; column<columns; ) {
@ -616,10 +582,13 @@ R_LoadSkys ( void ) {
int i;
QFile *f;
char name[64];
cvar_t *r_skyname;
r_skyname = Cvar_Get ("r_skyname","sky",CVAR_NONE, "");
for (i=0 ; i<6 ; i++) {
GL_Bind (SKY_TEX + i);
snprintf(name, sizeof(name), "gfx/env/bkgtst%s.tga", suf[i]);
snprintf(name, sizeof(name), "gfx/env/%s%s.tga",
r_skyname->string, suf[i]);
COM_FOpenFile (name, &f);
if (!f) {
Con_Printf ("Couldn't load %s\n", name);
@ -851,6 +820,8 @@ R_DrawSkyChain (msurface_t *s) {
vec3_t verts[MAX_CLIP_VERTS];
glpoly_t *p;
if (1)
{
c_sky = 0;
GL_Bind(solidskytexture);
@ -865,6 +836,29 @@ R_DrawSkyChain (msurface_t *s) {
}
}
}
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);
}
}
/*
R_ClearSkyBox
@ -923,9 +917,9 @@ 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; //, j, k;
// vec3_t v;
// float s, t;
#if 0
glEnable (GL_BLEND);
@ -961,7 +955,6 @@ R_DrawSkyBox (void) {
#endif
}
#endif // QUAKE2
/*
R_InitSky

View file

@ -239,6 +239,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 (void);
void R_ClearSkyBox (void);
void R_DrawSkyBox (void);
//
// gl_draw.c