mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2024-11-26 05:40:49 +00:00
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:
parent
6483ab1ad5
commit
54501eaed7
5 changed files with 65 additions and 72 deletions
|
@ -1080,7 +1080,12 @@ R_RenderView ( void ) {
|
||||||
glFogi (GL_FOG_MODE, GL_EXP2);
|
glFogi (GL_FOG_MODE, GL_EXP2);
|
||||||
glFogfv (GL_FOG_COLOR, colors);
|
glFogfv (GL_FOG_COLOR, colors);
|
||||||
glFogf (GL_FOG_DENSITY, (GLfloat) r_fog->value);
|
glFogf (GL_FOG_DENSITY, (GLfloat) r_fog->value);
|
||||||
glEnable(GL_FOG);
|
// 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 ();
|
R_RenderScene ();
|
||||||
R_DrawViewModel ();
|
R_DrawViewModel ();
|
||||||
|
|
|
@ -601,9 +601,7 @@ void R_NewMap (void)
|
||||||
skytexturenum = i;
|
skytexturenum = i;
|
||||||
cl.worldmodel->textures[i]->texturechain = NULL;
|
cl.worldmodel->textures[i]->texturechain = NULL;
|
||||||
}
|
}
|
||||||
#ifdef QUAKE2
|
|
||||||
R_LoadSkys ();
|
R_LoadSkys ();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/*
|
||||||
|
gl_rsurf.c - surrface-related refresh code
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
||||||
Please see the file "AUTHORS" for a list of contributors
|
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.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
// r_surf.c: surrface-related refresh code
|
|
||||||
|
|
||||||
#include "qtypes.h"
|
#include <qtypes.h>
|
||||||
#include "quakedef.h"
|
#include <quakedef.h>
|
||||||
#include "glquake.h"
|
#include <glquake.h>
|
||||||
#include "mathlib.h"
|
#include <mathlib.h>
|
||||||
#include <sys.h>
|
#include <sys.h>
|
||||||
|
|
||||||
int skytexturenum;
|
int skytexturenum;
|
||||||
|
@ -1321,9 +1321,7 @@ void R_DrawWorld (void)
|
||||||
|
|
||||||
glColor3f (1,1,1);
|
glColor3f (1,1,1);
|
||||||
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
||||||
#ifdef QUAKE2
|
|
||||||
R_ClearSkyBox ();
|
R_ClearSkyBox ();
|
||||||
#endif
|
|
||||||
|
|
||||||
R_RecursiveWorldNode (cl.worldmodel->nodes);
|
R_RecursiveWorldNode (cl.worldmodel->nodes);
|
||||||
|
|
||||||
|
@ -1331,9 +1329,7 @@ void R_DrawWorld (void)
|
||||||
|
|
||||||
R_BlendLightmaps ();
|
R_BlendLightmaps ();
|
||||||
|
|
||||||
#ifdef QUAKE2
|
|
||||||
R_DrawSkyBox ();
|
R_DrawSkyBox ();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1638,10 +1634,8 @@ void GL_BuildLightmaps (void)
|
||||||
GL_CreateSurfaceLightmap (m->surfaces + i);
|
GL_CreateSurfaceLightmap (m->surfaces + i);
|
||||||
if ( m->surfaces[i].flags & SURF_DRAWTURB )
|
if ( m->surfaces[i].flags & SURF_DRAWTURB )
|
||||||
continue;
|
continue;
|
||||||
#ifndef QUAKE2
|
|
||||||
if ( m->surfaces[i].flags & SURF_DRAWSKY )
|
if ( m->surfaces[i].flags & SURF_DRAWSKY )
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
BuildSurfaceDisplayList (m->surfaces + i);
|
BuildSurfaceDisplayList (m->surfaces + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
109
common/gl_warp.c
109
common/gl_warp.c
|
@ -27,11 +27,12 @@
|
||||||
Boston, MA 02111-1307, USA
|
Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qtypes.h"
|
#include <qtypes.h>
|
||||||
#include "quakedef.h"
|
#include <quakedef.h>
|
||||||
#include "glquake.h"
|
#include <glquake.h>
|
||||||
#include "mathlib.h"
|
#include <mathlib.h>
|
||||||
#include <sys.h>
|
#include <sys.h>
|
||||||
|
#include <console.h>
|
||||||
|
|
||||||
extern model_t *loadmodel;
|
extern model_t *loadmodel;
|
||||||
|
|
||||||
|
@ -295,6 +296,7 @@ EmitBothSkyLayers ( msurface_t *fa ) {
|
||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
R_DrawSkyChain
|
R_DrawSkyChain
|
||||||
*/
|
*/
|
||||||
|
@ -303,55 +305,19 @@ R_DrawSkyChain ( msurface_t *s ) {
|
||||||
|
|
||||||
msurface_t *fa;
|
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")
|
Quake 2 sky rendering ("skyboxes")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef QUAKE2
|
|
||||||
|
|
||||||
#define SKY_TEX 2000
|
#define SKY_TEX 2000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PCX Loading
|
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;
|
byte *pcx_rgb;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -460,8 +426,9 @@ void
|
||||||
LoadTGA (QFile *fin) {
|
LoadTGA (QFile *fin) {
|
||||||
|
|
||||||
int columns, rows, numPixels;
|
int columns, rows, numPixels;
|
||||||
byte *pixbuf;
|
byte *pixbuf;
|
||||||
int row, column;
|
int row, column;
|
||||||
|
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
|
||||||
|
|
||||||
targa_header.id_length = Qgetc(fin);
|
targa_header.id_length = Qgetc(fin);
|
||||||
targa_header.colormap_type = Qgetc(fin);
|
targa_header.colormap_type = Qgetc(fin);
|
||||||
|
@ -498,7 +465,6 @@ LoadTGA (QFile *fin) {
|
||||||
for(row=rows-1; row>=0; row--) {
|
for(row=rows-1; row>=0; row--) {
|
||||||
pixbuf = targa_rgba + row*columns*4;
|
pixbuf = targa_rgba + row*columns*4;
|
||||||
for(column=0; column<columns; column++) {
|
for(column=0; column<columns; column++) {
|
||||||
unsigned char red,green,blue,alphabyte;
|
|
||||||
switch (targa_header.pixel_size) {
|
switch (targa_header.pixel_size) {
|
||||||
case 24:
|
case 24:
|
||||||
|
|
||||||
|
@ -525,7 +491,7 @@ LoadTGA (QFile *fin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (targa_header.image_type==10) { // Runlength encoded RGB images
|
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--) {
|
for(row=rows-1; row>=0; row--) {
|
||||||
pixbuf = targa_rgba + row*columns*4;
|
pixbuf = targa_rgba + row*columns*4;
|
||||||
for(column=0; column<columns; ) {
|
for(column=0; column<columns; ) {
|
||||||
|
@ -613,13 +579,16 @@ char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
|
||||||
void
|
void
|
||||||
R_LoadSkys ( void ) {
|
R_LoadSkys ( void ) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
QFile *f;
|
QFile *f;
|
||||||
char name[64];
|
char name[64];
|
||||||
|
cvar_t *r_skyname;
|
||||||
|
|
||||||
|
r_skyname = Cvar_Get ("r_skyname","sky",CVAR_NONE, "");
|
||||||
for (i=0 ; i<6 ; i++) {
|
for (i=0 ; i<6 ; i++) {
|
||||||
GL_Bind (SKY_TEX + 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);
|
COM_FOpenFile (name, &f);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
Con_Printf ("Couldn't load %s\n", name);
|
Con_Printf ("Couldn't load %s\n", name);
|
||||||
|
@ -851,19 +820,44 @@ R_DrawSkyChain (msurface_t *s) {
|
||||||
vec3_t verts[MAX_CLIP_VERTS];
|
vec3_t verts[MAX_CLIP_VERTS];
|
||||||
glpoly_t *p;
|
glpoly_t *p;
|
||||||
|
|
||||||
c_sky = 0;
|
if (1)
|
||||||
GL_Bind(solidskytexture);
|
{
|
||||||
|
c_sky = 0;
|
||||||
|
GL_Bind(solidskytexture);
|
||||||
|
|
||||||
// calculate vertex values for sky box
|
// calculate vertex values for sky box
|
||||||
|
|
||||||
for (fa=s ; fa ; fa=fa->texturechain) {
|
for (fa=s ; fa ; fa=fa->texturechain) {
|
||||||
for (p=fa->polys ; p ; p=p->next) {
|
for (p=fa->polys ; p ; p=p->next) {
|
||||||
for (i=0 ; i<p->numverts ; i++) {
|
for (i=0 ; i<p->numverts ; i++) {
|
||||||
VectorSubtract (p->verts[i], r_origin, verts[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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -923,9 +917,9 @@ int skytexorder[6] = {0,2,1,3,4,5};
|
||||||
void
|
void
|
||||||
R_DrawSkyBox (void) {
|
R_DrawSkyBox (void) {
|
||||||
|
|
||||||
int i, j, k;
|
int i; //, j, k;
|
||||||
vec3_t v;
|
// vec3_t v;
|
||||||
float s, t;
|
// float s, t;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
glEnable (GL_BLEND);
|
glEnable (GL_BLEND);
|
||||||
|
@ -961,7 +955,6 @@ R_DrawSkyBox (void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QUAKE2
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
R_InitSky
|
R_InitSky
|
||||||
|
|
|
@ -239,6 +239,9 @@ void EmitBothSkyLayers (msurface_t *fa);
|
||||||
void EmitWaterPolys (msurface_t *fa);
|
void EmitWaterPolys (msurface_t *fa);
|
||||||
void EmitSkyPolys (msurface_t *fa);
|
void EmitSkyPolys (msurface_t *fa);
|
||||||
void R_DrawSkyChain (msurface_t *s);
|
void R_DrawSkyChain (msurface_t *s);
|
||||||
|
void R_LoadSkys (void);
|
||||||
|
void R_ClearSkyBox (void);
|
||||||
|
void R_DrawSkyBox (void);
|
||||||
|
|
||||||
//
|
//
|
||||||
// gl_draw.c
|
// gl_draw.c
|
||||||
|
|
Loading…
Reference in a new issue