mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-31 17:21:46 +00:00
merge in knghtbrd's work, minus his over-bright stuff (it causes textures to
not be drawn when multitexture is not available (or at least I think that's the condition)). More specificly, his altered blend states.
This commit is contained in:
parent
acb5f4b21a
commit
18a9900b21
10 changed files with 259 additions and 731 deletions
|
@ -75,7 +75,6 @@ typedef void (GLAPIENTRY *PRIORTEXFUNCPTR)(GLsizei, const GLuint *,
|
||||||
const GLclampf *);
|
const GLclampf *);
|
||||||
typedef void (GLAPIENTRY *TEXSUBIMAGEPTR)(int, int, int, int, int, int, int, int, void *);
|
typedef void (GLAPIENTRY *TEXSUBIMAGEPTR)(int, int, int, int, int, int, int, int, void *);
|
||||||
|
|
||||||
extern BINDTEXFUNCPTR bindTexFunc;
|
|
||||||
extern DELTEXFUNCPTR delTexFunc;
|
extern DELTEXFUNCPTR delTexFunc;
|
||||||
extern TEXSUBIMAGEPTR TexSubImage2DFunc;
|
extern TEXSUBIMAGEPTR TexSubImage2DFunc;
|
||||||
|
|
||||||
|
@ -176,8 +175,6 @@ extern texture_t *r_notexture_mip;
|
||||||
extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
|
extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
|
||||||
|
|
||||||
extern qboolean envmap;
|
extern qboolean envmap;
|
||||||
extern int currenttexture;
|
|
||||||
extern int cnttextures[2];
|
|
||||||
extern int particletexture;
|
extern int particletexture;
|
||||||
extern int netgraphtexture; // netgraph texture
|
extern int netgraphtexture; // netgraph texture
|
||||||
extern int playertextures;
|
extern int playertextures;
|
||||||
|
@ -195,6 +192,7 @@ extern cvar_t *r_lightmap;
|
||||||
extern cvar_t *r_shadows;
|
extern cvar_t *r_shadows;
|
||||||
extern cvar_t *r_mirroralpha;
|
extern cvar_t *r_mirroralpha;
|
||||||
extern cvar_t *r_wateralpha;
|
extern cvar_t *r_wateralpha;
|
||||||
|
extern cvar_t *r_waterripple;
|
||||||
extern cvar_t *r_dynamic;
|
extern cvar_t *r_dynamic;
|
||||||
extern cvar_t *r_novis;
|
extern cvar_t *r_novis;
|
||||||
extern cvar_t *r_netgraph;
|
extern cvar_t *r_netgraph;
|
||||||
|
@ -233,7 +231,6 @@ extern const char *gl_version;
|
||||||
extern const char *gl_extensions;
|
extern const char *gl_extensions;
|
||||||
|
|
||||||
void R_TranslatePlayerSkin (int playernum);
|
void R_TranslatePlayerSkin (int playernum);
|
||||||
void GL_Bind (int texnum);
|
|
||||||
|
|
||||||
// Multitexture
|
// Multitexture
|
||||||
#define TEXTURE0_SGIS 0x835E
|
#define TEXTURE0_SGIS 0x835E
|
||||||
|
@ -263,8 +260,7 @@ 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 (char *);
|
void R_LoadSkys (char *);
|
||||||
void R_ClearSkyBox (void);
|
void R_DrawSky (void);
|
||||||
void R_DrawSkyBox (void);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// gl_draw.c
|
// gl_draw.c
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "quakefs.h"
|
#include "quakefs.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "client.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -703,8 +704,9 @@ void Draw_ConsoleBackground (int lines)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw_AltString8 (vid.conwidth - strlen(cl_verstring->string)*8 - 11,
|
if (!cls.download)
|
||||||
lines-14, cl_verstring->string);
|
Draw_AltString8 (vid.conwidth - strlen(cl_verstring->string)
|
||||||
|
* 8 - 11, lines-14, cl_verstring->string);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,20 +122,6 @@ typedef struct
|
||||||
gltexture_t gltextures[MAX_GLTEXTURES];
|
gltexture_t gltextures[MAX_GLTEXTURES];
|
||||||
int numgltextures;
|
int numgltextures;
|
||||||
|
|
||||||
void GL_Bind (int texnum)
|
|
||||||
{
|
|
||||||
if (gl_nobind->value)
|
|
||||||
texnum = char_texture;
|
|
||||||
if (currenttexture == texnum)
|
|
||||||
return;
|
|
||||||
currenttexture = texnum;
|
|
||||||
#ifdef _WIN32
|
|
||||||
bindTexFunc (GL_TEXTURE_2D, texnum);
|
|
||||||
#else
|
|
||||||
glBindTexture (GL_TEXTURE_2D, texnum);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============================================================================
|
=============================================================================
|
||||||
|
@ -204,7 +190,7 @@ int scrap_uploads;
|
||||||
void Scrap_Upload (void)
|
void Scrap_Upload (void)
|
||||||
{
|
{
|
||||||
scrap_uploads++;
|
scrap_uploads++;
|
||||||
GL_Bind(scrap_texnum);
|
glBindTexture (GL_TEXTURE_2D, scrap_texnum);
|
||||||
GL_Upload8 (scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, true);
|
GL_Upload8 (scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, true);
|
||||||
scrap_dirty = false;
|
scrap_dirty = false;
|
||||||
}
|
}
|
||||||
|
@ -376,9 +362,9 @@ void Draw_TextureMode_f (void)
|
||||||
{
|
{
|
||||||
if (glt->mipmap)
|
if (glt->mipmap)
|
||||||
{
|
{
|
||||||
GL_Bind (glt->texnum);
|
glBindTexture (GL_TEXTURE_2D, glt->texnum);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
|
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
|
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,7 +465,7 @@ void Draw_Character8 (int x, int y, int num)
|
||||||
fcol = col*0.0625;
|
fcol = col*0.0625;
|
||||||
size = 0.0625;
|
size = 0.0625;
|
||||||
|
|
||||||
GL_Bind (char_texture);
|
glBindTexture (GL_TEXTURE_2D, char_texture);
|
||||||
|
|
||||||
glColor3f (0.5, 0.5, 0.5);
|
glColor3f (0.5, 0.5, 0.5);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
@ -536,7 +522,7 @@ void Draw_Crosshair(void)
|
||||||
|
|
||||||
pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value];
|
pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value];
|
||||||
glColor4ubv ( pColor );
|
glColor4ubv ( pColor );
|
||||||
GL_Bind (cs_texture);
|
glBindTexture (GL_TEXTURE_2D, cs_texture);
|
||||||
|
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
glTexCoord2f (0, 0);
|
glTexCoord2f (0, 0);
|
||||||
|
@ -581,7 +567,7 @@ void Draw_Pic (int x, int y, qpic_t *pic)
|
||||||
Scrap_Upload ();
|
Scrap_Upload ();
|
||||||
gl = (glpic_t *)pic->data;
|
gl = (glpic_t *)pic->data;
|
||||||
glColor3f (0.4, 0.4, 0.4);
|
glColor3f (0.4, 0.4, 0.4);
|
||||||
GL_Bind (gl->texnum);
|
glBindTexture (GL_TEXTURE_2D, gl->texnum);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
glTexCoord2f (gl->sl, gl->tl);
|
glTexCoord2f (gl->sl, gl->tl);
|
||||||
glVertex2f (x, y);
|
glVertex2f (x, y);
|
||||||
|
@ -607,7 +593,7 @@ void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
|
||||||
Scrap_Upload ();
|
Scrap_Upload ();
|
||||||
gl = (glpic_t *)pic->data;
|
gl = (glpic_t *)pic->data;
|
||||||
glColor4f (0.4, 0.4, 0.4, alpha);
|
glColor4f (0.4, 0.4, 0.4, alpha);
|
||||||
GL_Bind (gl->texnum);
|
glBindTexture (GL_TEXTURE_2D, gl->texnum);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
glTexCoord2f (gl->sl, gl->tl);
|
glTexCoord2f (gl->sl, gl->tl);
|
||||||
glVertex2f (x, y);
|
glVertex2f (x, y);
|
||||||
|
@ -641,7 +627,7 @@ void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int h
|
||||||
newth = newtl + (height*oldglheight)/pic->height;
|
newth = newtl + (height*oldglheight)/pic->height;
|
||||||
|
|
||||||
glColor3f (0.4, 0.4, 0.4);
|
glColor3f (0.4, 0.4, 0.4);
|
||||||
GL_Bind (gl->texnum);
|
glBindTexture (GL_TEXTURE_2D, gl->texnum);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
glTexCoord2f (newsl, newtl);
|
glTexCoord2f (newsl, newtl);
|
||||||
glVertex2f (x, y);
|
glVertex2f (x, y);
|
||||||
|
@ -686,7 +672,7 @@ void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation)
|
||||||
byte *src;
|
byte *src;
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
GL_Bind (translate_texture);
|
glBindTexture (GL_TEXTURE_2D, translate_texture);
|
||||||
|
|
||||||
c = pic->width * pic->height;
|
c = pic->width * pic->height;
|
||||||
|
|
||||||
|
@ -779,7 +765,7 @@ Draw_ConsoleBackground ( int lines )
|
||||||
glColor4f (0.5, 0.5, 0.5, alpha);
|
glColor4f (0.5, 0.5, 0.5, alpha);
|
||||||
|
|
||||||
// draw the console texture
|
// draw the console texture
|
||||||
GL_Bind (gl->texnum);
|
glBindTexture (GL_TEXTURE_2D, gl->texnum);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
glTexCoord2f (gl->sl, gl->tl + ofs);
|
glTexCoord2f (gl->sl, gl->tl + ofs);
|
||||||
glVertex2f (0, 0);
|
glVertex2f (0, 0);
|
||||||
|
@ -822,7 +808,7 @@ refresh window.
|
||||||
void Draw_TileClear (int x, int y, int w, int h)
|
void Draw_TileClear (int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
glColor3f (0.5, 0.5, 0.5);
|
glColor3f (0.5, 0.5, 0.5);
|
||||||
GL_Bind (*(int *)draw_backtile->data);
|
glBindTexture (GL_TEXTURE_2D, *(int *)draw_backtile->data);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
glTexCoord2f (x/64.0, y/64.0);
|
glTexCoord2f (x/64.0, y/64.0);
|
||||||
glVertex2f (x, y);
|
glVertex2f (x, y);
|
||||||
|
@ -1380,7 +1366,7 @@ SetupTexture:
|
||||||
glt->height = height;
|
glt->height = height;
|
||||||
glt->mipmap = mipmap;
|
glt->mipmap = mipmap;
|
||||||
|
|
||||||
GL_Bind(glt->texnum);
|
glBindTexture (GL_TEXTURE_2D, glt->texnum);
|
||||||
|
|
||||||
GL_Upload8 (data, width, height, mipmap, alpha);
|
GL_Upload8 (data, width, height, mipmap, alpha);
|
||||||
|
|
||||||
|
@ -1399,17 +1385,10 @@ int GL_LoadPicTexture (qpic_t *pic)
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
static GLenum oldtarget = 0; // TEXTURE0_SGIS;
|
|
||||||
|
|
||||||
void GL_SelectTexture (GLenum target)
|
void GL_SelectTexture (GLenum target)
|
||||||
{
|
{
|
||||||
if (!gl_mtexable)
|
if (!gl_mtexable)
|
||||||
return;
|
return;
|
||||||
qglSelectTexture (target + gl_mtex_enum);
|
qglSelectTexture (target + gl_mtex_enum);
|
||||||
if (target == oldtarget)
|
|
||||||
return;
|
|
||||||
cnttextures[oldtarget] = currenttexture;
|
|
||||||
currenttexture = cnttextures[target];
|
|
||||||
oldtarget = target;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ void R_NetGraph (void)
|
||||||
Draw_String8 (8, y, st);
|
Draw_String8 (8, y, st);
|
||||||
y += 8;
|
y += 8;
|
||||||
|
|
||||||
GL_Bind(netgraphtexture);
|
glBindTexture (GL_TEXTURE_2D, netgraphtexture);
|
||||||
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format,
|
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format,
|
||||||
NET_TIMINGS, NET_GRAPHHEIGHT, 0, GL_RGBA,
|
NET_TIMINGS, NET_GRAPHHEIGHT, 0, GL_RGBA,
|
||||||
|
|
|
@ -494,7 +494,7 @@ void R_DrawParticles (void)
|
||||||
float scale;
|
float scale;
|
||||||
qboolean alphaTestEnabled;
|
qboolean alphaTestEnabled;
|
||||||
|
|
||||||
GL_Bind(particletexture);
|
glBindTexture (GL_TEXTURE_2D, particletexture);
|
||||||
alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
|
alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
|
||||||
|
|
||||||
if (alphaTestEnabled)
|
if (alphaTestEnabled)
|
||||||
|
|
|
@ -60,9 +60,6 @@ int c_brush_polys, c_alias_polys;
|
||||||
|
|
||||||
qboolean envmap; // true during envmap command capture
|
qboolean envmap; // true during envmap command capture
|
||||||
|
|
||||||
int currenttexture = -1; // to avoid unnecessary texture sets
|
|
||||||
|
|
||||||
int cnttextures[2] = {-1, -1}; // cached
|
|
||||||
|
|
||||||
int particletexture; // little dot for particles
|
int particletexture; // little dot for particles
|
||||||
int playertextures; // up to 16 color translated skins
|
int playertextures; // up to 16 color translated skins
|
||||||
|
@ -103,6 +100,7 @@ cvar_t *r_lightmap;
|
||||||
cvar_t *r_shadows;
|
cvar_t *r_shadows;
|
||||||
cvar_t *r_mirroralpha;
|
cvar_t *r_mirroralpha;
|
||||||
cvar_t *r_wateralpha;
|
cvar_t *r_wateralpha;
|
||||||
|
cvar_t *r_waterripple;
|
||||||
cvar_t *r_dynamic;
|
cvar_t *r_dynamic;
|
||||||
cvar_t *r_novis;
|
cvar_t *r_novis;
|
||||||
cvar_t *r_netgraph;
|
cvar_t *r_netgraph;
|
||||||
|
@ -292,7 +290,7 @@ void R_DrawSpriteModel (entity_t *e)
|
||||||
|
|
||||||
GL_DisableMultitexture();
|
GL_DisableMultitexture();
|
||||||
|
|
||||||
GL_Bind(frame->gl_texturenum);
|
glBindTexture (GL_TEXTURE_2D, frame->gl_texturenum);
|
||||||
|
|
||||||
glEnable (GL_ALPHA_TEST);
|
glEnable (GL_ALPHA_TEST);
|
||||||
glBegin (GL_QUADS);
|
glBegin (GL_QUADS);
|
||||||
|
@ -364,8 +362,8 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
|
||||||
trivertx_t *verts;
|
trivertx_t *verts;
|
||||||
int *order;
|
int *order;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
lastposenum = posenum;
|
lastposenum = posenum;
|
||||||
|
|
||||||
verts = (trivertx_t *)((byte *)paliashdr + paliashdr->posedata);
|
verts = (trivertx_t *)((byte *)paliashdr + paliashdr->posedata);
|
||||||
verts += posenum * paliashdr->poseverts;
|
verts += posenum * paliashdr->poseverts;
|
||||||
|
@ -593,7 +591,7 @@ void R_DrawAliasModel (entity_t *e)
|
||||||
|
|
||||||
GL_DisableMultitexture();
|
GL_DisableMultitexture();
|
||||||
|
|
||||||
glPushMatrix ();
|
glPushMatrix ();
|
||||||
R_RotateForEntity (e);
|
R_RotateForEntity (e);
|
||||||
|
|
||||||
if (!strcmp (clmodel->name, "progs/eyes.mdl") ) {
|
if (!strcmp (clmodel->name, "progs/eyes.mdl") ) {
|
||||||
|
@ -606,7 +604,7 @@ void R_DrawAliasModel (entity_t *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
anim = (int)(cl.time*10) & 3;
|
anim = (int)(cl.time*10) & 3;
|
||||||
GL_Bind(paliashdr->gl_texturenum[currententity->skinnum][anim]);
|
glBindTexture (GL_TEXTURE_2D, paliashdr->gl_texturenum[currententity->skinnum][anim]);
|
||||||
|
|
||||||
// we can't dynamically colormap textures, so they are cached
|
// we can't dynamically colormap textures, so they are cached
|
||||||
// seperately for the players. Heads are just uncolored.
|
// seperately for the players. Heads are just uncolored.
|
||||||
|
@ -618,7 +616,7 @@ void R_DrawAliasModel (entity_t *e)
|
||||||
R_TranslatePlayerSkin(i);
|
R_TranslatePlayerSkin(i);
|
||||||
}
|
}
|
||||||
if (i >= 0 && i<MAX_CLIENTS)
|
if (i >= 0 && i<MAX_CLIENTS)
|
||||||
GL_Bind(playertextures + i);
|
glBindTexture (GL_TEXTURE_2D, playertextures + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gl_smoothmodels->value)
|
if (gl_smoothmodels->value)
|
||||||
|
|
|
@ -114,7 +114,7 @@ void R_InitParticleTexture (void)
|
||||||
// particle texture
|
// particle texture
|
||||||
//
|
//
|
||||||
particletexture = texture_extension_number++;
|
particletexture = texture_extension_number++;
|
||||||
GL_Bind(particletexture);
|
glBindTexture (GL_TEXTURE_2D, particletexture);
|
||||||
|
|
||||||
for (x=0 ; x<8 ; x++)
|
for (x=0 ; x<8 ; x++)
|
||||||
{
|
{
|
||||||
|
@ -238,6 +238,7 @@ void R_Init (void)
|
||||||
r_shadows = Cvar_Get("r_shadows", "0", CVAR_NONE, "None");
|
r_shadows = Cvar_Get("r_shadows", "0", CVAR_NONE, "None");
|
||||||
r_mirroralpha = Cvar_Get("r_mirroralpha", "1", CVAR_NONE, "None");
|
r_mirroralpha = Cvar_Get("r_mirroralpha", "1", CVAR_NONE, "None");
|
||||||
r_wateralpha = Cvar_Get("r_wateralpha", "1", CVAR_NONE, "None");
|
r_wateralpha = Cvar_Get("r_wateralpha", "1", CVAR_NONE, "None");
|
||||||
|
r_waterripple = Cvar_Get ("r_waterripple", "0", CVAR_NONE, "None");
|
||||||
r_dynamic = Cvar_Get("r_dynamic", "1", CVAR_NONE, "None");
|
r_dynamic = Cvar_Get("r_dynamic", "1", CVAR_NONE, "None");
|
||||||
r_novis = Cvar_Get("r_novis", "0", CVAR_NONE, "None");
|
r_novis = Cvar_Get("r_novis", "0", CVAR_NONE, "None");
|
||||||
r_speeds = Cvar_Get("r_speeds", "0", CVAR_NONE, "None");
|
r_speeds = Cvar_Get("r_speeds", "0", CVAR_NONE, "None");
|
||||||
|
@ -247,7 +248,7 @@ void R_Init (void)
|
||||||
gl_texsort = Cvar_Get("gl_texsort", "1", CVAR_NONE, "None");
|
gl_texsort = Cvar_Get("gl_texsort", "1", CVAR_NONE, "None");
|
||||||
|
|
||||||
if (gl_mtexable)
|
if (gl_mtexable)
|
||||||
gl_texsort->value = 0.0;
|
Cvar_SetValue(gl_texsort, 0.0);
|
||||||
|
|
||||||
gl_cull = Cvar_Get("gl_cull", "1", CVAR_NONE, "None");
|
gl_cull = Cvar_Get("gl_cull", "1", CVAR_NONE, "None");
|
||||||
gl_smoothmodels = Cvar_Get("gl_smoothmodels", "1", CVAR_NONE, "None");
|
gl_smoothmodels = Cvar_Get("gl_smoothmodels", "1", CVAR_NONE, "None");
|
||||||
|
@ -361,7 +362,7 @@ void R_TranslatePlayerSkin (int playernum)
|
||||||
|
|
||||||
// because this happens during gameplay, do it fast
|
// because this happens during gameplay, do it fast
|
||||||
// instead of sending it through gl_upload 8
|
// instead of sending it through gl_upload 8
|
||||||
GL_Bind(playertextures + playernum);
|
glBindTexture (GL_TEXTURE_2D, playertextures + playernum);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
s = 320*200;
|
s = 320*200;
|
||||||
|
|
|
@ -75,7 +75,7 @@ cvar_t *gl_colorlights;
|
||||||
#define BLOCK_WIDTH 128
|
#define BLOCK_WIDTH 128
|
||||||
#define BLOCK_HEIGHT 128
|
#define BLOCK_HEIGHT 128
|
||||||
|
|
||||||
#define MAX_LIGHTMAPS 256
|
#define MAX_LIGHTMAPS 64
|
||||||
int active_lightmaps;
|
int active_lightmaps;
|
||||||
|
|
||||||
typedef struct glRect_s {
|
typedef struct glRect_s {
|
||||||
|
@ -336,9 +336,6 @@ extern int solidskytexture;
|
||||||
extern int alphaskytexture;
|
extern int alphaskytexture;
|
||||||
extern float speedscale; // for top sky and bottom sky
|
extern float speedscale; // for top sky and bottom sky
|
||||||
|
|
||||||
void DrawGLWaterPoly (glpoly_t *p);
|
|
||||||
void DrawGLWaterPolyLightmap (glpoly_t *p);
|
|
||||||
|
|
||||||
lpMTexFUNC qglMTexCoord2f = NULL;
|
lpMTexFUNC qglMTexCoord2f = NULL;
|
||||||
lpSelTexFUNC qglSelectTexture = NULL;
|
lpSelTexFUNC qglSelectTexture = NULL;
|
||||||
|
|
||||||
|
@ -378,14 +375,13 @@ void R_DrawSequentialPoly (msurface_t *s)
|
||||||
float *v;
|
float *v;
|
||||||
int i;
|
int i;
|
||||||
texture_t *t;
|
texture_t *t;
|
||||||
vec3_t nv;
|
|
||||||
glRect_t *theRect;
|
glRect_t *theRect;
|
||||||
|
|
||||||
//
|
//
|
||||||
// normal lightmaped poly
|
// normal lightmaped poly
|
||||||
//
|
//
|
||||||
|
|
||||||
if (! (s->flags & (SURF_DRAWSKY|SURF_DRAWTURB|SURF_UNDERWATER) ) )
|
if (!(s->flags & (SURF_DRAWSKY|SURF_DRAWTURB)))
|
||||||
{
|
{
|
||||||
R_RenderDynamicLightmaps (s);
|
R_RenderDynamicLightmaps (s);
|
||||||
if (gl_mtexable)
|
if (gl_mtexable)
|
||||||
|
@ -395,11 +391,11 @@ void R_DrawSequentialPoly (msurface_t *s)
|
||||||
t = R_TextureAnimation (s->texinfo->texture);
|
t = R_TextureAnimation (s->texinfo->texture);
|
||||||
// Binds world to texture env 0
|
// Binds world to texture env 0
|
||||||
GL_SelectTexture(0);
|
GL_SelectTexture(0);
|
||||||
GL_Bind (t->gl_texturenum);
|
glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
|
||||||
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
// Binds lightmap to texenv 1
|
// Binds lightmap to texenv 1
|
||||||
GL_EnableMultitexture(); // Same as SelectTexture (TEXTURE1)
|
GL_EnableMultitexture(); // Same as SelectTexture (TEXTURE1)
|
||||||
GL_Bind (lightmap_textures + s->lightmaptexturenum);
|
glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum);
|
||||||
i = s->lightmaptexturenum;
|
i = s->lightmaptexturenum;
|
||||||
if (lightmap_modified[i])
|
if (lightmap_modified[i])
|
||||||
{
|
{
|
||||||
|
@ -414,6 +410,7 @@ void R_DrawSequentialPoly (msurface_t *s)
|
||||||
theRect->w = 0;
|
theRect->w = 0;
|
||||||
}
|
}
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
v = p->verts[0];
|
v = p->verts[0];
|
||||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
||||||
|
@ -428,22 +425,22 @@ void R_DrawSequentialPoly (msurface_t *s)
|
||||||
p = s->polys;
|
p = s->polys;
|
||||||
|
|
||||||
t = R_TextureAnimation (s->texinfo->texture);
|
t = R_TextureAnimation (s->texinfo->texture);
|
||||||
GL_Bind (t->gl_texturenum);
|
glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
|
||||||
glBegin (GL_POLYGON);
|
glBegin (GL_POLYGON);
|
||||||
v = p->verts[0];
|
v = p->verts[0];
|
||||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
||||||
{
|
{
|
||||||
glTexCoord2f (v[3], v[4]);
|
glTexCoord2fv (&v[3]);
|
||||||
glVertex3fv (v);
|
glVertex3fv (v);
|
||||||
}
|
}
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
|
||||||
GL_Bind (lightmap_textures + s->lightmaptexturenum);
|
glBindTexture (GL_TEXTURE_2D, lightmap_textures + s->lightmaptexturenum);
|
||||||
glBegin (GL_POLYGON);
|
glBegin (GL_POLYGON);
|
||||||
v = p->verts[0];
|
v = p->verts[0];
|
||||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
||||||
{
|
{
|
||||||
glTexCoord2f (v[5], v[6]);
|
glTexCoord2fv (&v[5]);
|
||||||
glVertex3fv (v);
|
glVertex3fv (v);
|
||||||
}
|
}
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
@ -457,139 +454,12 @@ void R_DrawSequentialPoly (msurface_t *s)
|
||||||
|
|
||||||
if (s->flags & SURF_DRAWTURB)
|
if (s->flags & SURF_DRAWTURB)
|
||||||
{
|
{
|
||||||
GL_DisableMultitexture();
|
|
||||||
GL_Bind (s->texinfo->texture->gl_texturenum);
|
|
||||||
EmitWaterPolys (s);
|
EmitWaterPolys (s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// subdivided sky warp
|
|
||||||
//
|
|
||||||
if (s->flags & SURF_DRAWSKY)
|
|
||||||
{
|
|
||||||
GL_DisableMultitexture();
|
|
||||||
GL_Bind (solidskytexture);
|
|
||||||
speedscale = realtime*8;
|
|
||||||
speedscale -= (int)speedscale & ~127;
|
|
||||||
|
|
||||||
EmitSkyPolys (s);
|
|
||||||
|
|
||||||
GL_Bind (alphaskytexture);
|
|
||||||
speedscale = realtime*16;
|
|
||||||
speedscale -= (int)speedscale & ~127;
|
|
||||||
EmitSkyPolys (s);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// underwater warped with lightmap
|
|
||||||
//
|
|
||||||
R_RenderDynamicLightmaps (s);
|
|
||||||
if (gl_mtexable)
|
|
||||||
{
|
|
||||||
p = s->polys;
|
|
||||||
|
|
||||||
t = R_TextureAnimation (s->texinfo->texture);
|
|
||||||
GL_SelectTexture(0);
|
|
||||||
GL_Bind (t->gl_texturenum);
|
|
||||||
GL_EnableMultitexture();
|
|
||||||
GL_Bind (lightmap_textures + s->lightmaptexturenum);
|
|
||||||
i = s->lightmaptexturenum;
|
|
||||||
if (lightmap_modified[i])
|
|
||||||
{
|
|
||||||
lightmap_modified[i] = false;
|
|
||||||
theRect = &lightmap_rectchange[i];
|
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t,
|
|
||||||
BLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE,
|
|
||||||
lightmaps+(i* BLOCK_HEIGHT + theRect->t) *BLOCK_WIDTH*lightmap_bytes);
|
|
||||||
theRect->l = BLOCK_WIDTH;
|
|
||||||
theRect->t = BLOCK_HEIGHT;
|
|
||||||
theRect->h = 0;
|
|
||||||
theRect->w = 0;
|
|
||||||
}
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
glBegin (GL_TRIANGLE_FAN);
|
|
||||||
v = p->verts[0];
|
|
||||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
|
||||||
{
|
|
||||||
qglMTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
|
|
||||||
qglMTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
|
|
||||||
|
|
||||||
nv[0] = v[0] + 8*sin(v[1]*0.05+realtime)*sin(v[2]*0.05+realtime);
|
|
||||||
nv[1] = v[1] + 8*sin(v[0]*0.05+realtime)*sin(v[2]*0.05+realtime);
|
|
||||||
nv[2] = v[2];
|
|
||||||
|
|
||||||
glVertex3fv (nv);
|
|
||||||
}
|
|
||||||
glEnd ();
|
|
||||||
} else {
|
|
||||||
p = s->polys;
|
|
||||||
|
|
||||||
t = R_TextureAnimation (s->texinfo->texture);
|
|
||||||
GL_Bind (t->gl_texturenum);
|
|
||||||
DrawGLWaterPoly (p);
|
|
||||||
|
|
||||||
GL_Bind (lightmap_textures + s->lightmaptexturenum);
|
|
||||||
DrawGLWaterPolyLightmap (p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
DrawGLWaterPoly
|
|
||||||
|
|
||||||
Warp the vertex coordinates
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
void DrawGLWaterPoly (glpoly_t *p)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
float *v;
|
|
||||||
vec3_t nv;
|
|
||||||
|
|
||||||
GL_DisableMultitexture();
|
|
||||||
|
|
||||||
glBegin (GL_TRIANGLE_FAN);
|
|
||||||
v = p->verts[0];
|
|
||||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
|
||||||
{
|
|
||||||
glTexCoord2f (v[3], v[4]);
|
|
||||||
|
|
||||||
nv[0] = v[0] + 8*sin(v[1]*0.05+realtime)*sin(v[2]*0.05+realtime);
|
|
||||||
nv[1] = v[1] + 8*sin(v[0]*0.05+realtime)*sin(v[2]*0.05+realtime);
|
|
||||||
nv[2] = v[2];
|
|
||||||
|
|
||||||
glVertex3fv (nv);
|
|
||||||
}
|
|
||||||
glEnd ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawGLWaterPolyLightmap (glpoly_t *p)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
float *v;
|
|
||||||
vec3_t nv;
|
|
||||||
|
|
||||||
GL_DisableMultitexture();
|
|
||||||
|
|
||||||
glBegin (GL_TRIANGLE_FAN);
|
|
||||||
v = p->verts[0];
|
|
||||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
|
||||||
{
|
|
||||||
glTexCoord2f (v[5], v[6]);
|
|
||||||
|
|
||||||
nv[0] = v[0] + 8*sin(v[1]*0.05+realtime)*sin(v[2]*0.05+realtime);
|
|
||||||
nv[1] = v[1] + 8*sin(v[0]*0.05+realtime)*sin(v[2]*0.05+realtime);
|
|
||||||
nv[2] = v[2];
|
|
||||||
|
|
||||||
glVertex3fv (nv);
|
|
||||||
}
|
|
||||||
glEnd ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
DrawGLPoly
|
DrawGLPoly
|
||||||
|
@ -604,7 +474,7 @@ void DrawGLPoly (glpoly_t *p)
|
||||||
v = p->verts[0];
|
v = p->verts[0];
|
||||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
||||||
{
|
{
|
||||||
glTexCoord2f (v[3], v[4]);
|
glTexCoord2fv (&v[3]);
|
||||||
glVertex3fv (v);
|
glVertex3fv (v);
|
||||||
}
|
}
|
||||||
glEnd ();
|
glEnd ();
|
||||||
|
@ -635,21 +505,11 @@ void R_BlendLightmaps (void)
|
||||||
p = lightmap_polys[i];
|
p = lightmap_polys[i];
|
||||||
if (!p)
|
if (!p)
|
||||||
continue;
|
continue;
|
||||||
GL_Bind(lightmap_textures+i);
|
glBindTexture (GL_TEXTURE_2D, lightmap_textures+i);
|
||||||
if (lightmap_modified[i])
|
if (lightmap_modified[i])
|
||||||
{
|
{
|
||||||
lightmap_modified[i] = false;
|
lightmap_modified[i] = false;
|
||||||
theRect = &lightmap_rectchange[i];
|
theRect = &lightmap_rectchange[i];
|
||||||
// theRect->l = 0;
|
|
||||||
// theRect->t = 0;
|
|
||||||
// theRect->w = BLOCK_WIDTH;
|
|
||||||
// theRect->h = BLOCK_HEIGHT;
|
|
||||||
// glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes
|
|
||||||
// , BLOCK_WIDTH, BLOCK_HEIGHT, 0,
|
|
||||||
// gl_lightmap_format, GL_UNSIGNED_BYTE, lightmaps+i*BLOCK_WIDTH*BLOCK_HEIGHT*lightmap_bytes);
|
|
||||||
// glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes
|
|
||||||
// , BLOCK_WIDTH, theRect->h, 0,
|
|
||||||
// gl_lightmap_format, GL_UNSIGNED_BYTE, lightmaps+(i*BLOCK_HEIGHT+theRect->t)*BLOCK_WIDTH*lightmap_bytes);
|
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t,
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t,
|
||||||
BLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE,
|
BLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE,
|
||||||
lightmaps+(i* BLOCK_HEIGHT + theRect->t) *BLOCK_WIDTH*lightmap_bytes);
|
lightmaps+(i* BLOCK_HEIGHT + theRect->t) *BLOCK_WIDTH*lightmap_bytes);
|
||||||
|
@ -660,23 +520,14 @@ void R_BlendLightmaps (void)
|
||||||
}
|
}
|
||||||
for ( ; p ; p=p->chain)
|
for ( ; p ; p=p->chain)
|
||||||
{
|
{
|
||||||
// if (p->flags & SURF_UNDERWATER)
|
glBegin (GL_POLYGON);
|
||||||
// DrawGLWaterPolyLightmap (p);
|
v = p->verts[0];
|
||||||
if (((r_viewleaf->contents==CONTENTS_EMPTY && (p->flags & SURF_UNDERWATER)) ||
|
for (j=0 ; j<p->numverts ; j++, v+= VERTEXSIZE)
|
||||||
(r_viewleaf->contents!=CONTENTS_EMPTY && !(p->flags & SURF_UNDERWATER)))
|
|
||||||
&& !(p->flags & SURF_DONTWARP))
|
|
||||||
DrawGLWaterPolyLightmap (p);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
glBegin (GL_POLYGON);
|
glTexCoord2fv (&v[5]);
|
||||||
v = p->verts[0];
|
glVertex3fv (v);
|
||||||
for (j=0 ; j<p->numverts ; j++, v+= VERTEXSIZE)
|
|
||||||
{
|
|
||||||
glTexCoord2f (v[5], v[6]);
|
|
||||||
glVertex3fv (v);
|
|
||||||
}
|
|
||||||
glEnd ();
|
|
||||||
}
|
}
|
||||||
|
glEnd ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,12 +554,12 @@ void R_RenderBrushPoly (msurface_t *fa)
|
||||||
|
|
||||||
if (fa->flags & SURF_DRAWSKY)
|
if (fa->flags & SURF_DRAWSKY)
|
||||||
{ // warp texture, no lightmaps
|
{ // warp texture, no lightmaps
|
||||||
EmitBothSkyLayers (fa);
|
// EmitBothSkyLayers (fa);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
t = R_TextureAnimation (fa->texinfo->texture);
|
t = R_TextureAnimation (fa->texinfo->texture);
|
||||||
GL_Bind (t->gl_texturenum);
|
glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
|
||||||
|
|
||||||
if (fa->flags & SURF_DRAWTURB)
|
if (fa->flags & SURF_DRAWTURB)
|
||||||
{ // warp texture, no lightmaps
|
{ // warp texture, no lightmaps
|
||||||
|
@ -716,12 +567,7 @@ void R_RenderBrushPoly (msurface_t *fa)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((r_viewleaf->contents==CONTENTS_EMPTY && (fa->flags & SURF_UNDERWATER)) ||
|
DrawGLPoly (fa->polys);
|
||||||
(r_viewleaf->contents!=CONTENTS_EMPTY && !(fa->flags & SURF_UNDERWATER)))
|
|
||||||
&& !(fa->flags & SURF_DONTWARP))
|
|
||||||
DrawGLWaterPoly (fa->polys);
|
|
||||||
else
|
|
||||||
DrawGLPoly (fa->polys);
|
|
||||||
|
|
||||||
// add the poly to the proper lightmap chain
|
// add the poly to the proper lightmap chain
|
||||||
|
|
||||||
|
@ -855,7 +701,7 @@ void R_DrawWaterSurfaces (void)
|
||||||
// go back to the world matrix
|
// go back to the world matrix
|
||||||
//
|
//
|
||||||
|
|
||||||
glLoadMatrixf (r_world_matrix);
|
glLoadMatrixf (r_world_matrix);
|
||||||
|
|
||||||
if (r_wateralpha->value < 1.0) {
|
if (r_wateralpha->value < 1.0) {
|
||||||
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
|
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
|
||||||
|
@ -868,7 +714,7 @@ void R_DrawWaterSurfaces (void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for ( s = waterchain ; s ; s=s->texturechain) {
|
for ( s = waterchain ; s ; s=s->texturechain) {
|
||||||
GL_Bind (s->texinfo->texture->gl_texturenum);
|
glBindTexture (GL_TEXTURE_2D, s->texinfo->texture->gl_texturenum);
|
||||||
EmitWaterPolys (s);
|
EmitWaterPolys (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,7 +734,7 @@ void R_DrawWaterSurfaces (void)
|
||||||
|
|
||||||
// set modulate mode explicitly
|
// set modulate mode explicitly
|
||||||
|
|
||||||
GL_Bind (t->gl_texturenum);
|
glBindTexture (GL_TEXTURE_2D, t->gl_texturenum);
|
||||||
|
|
||||||
for ( ; s ; s=s->texturechain)
|
for ( ; s ; s=s->texturechain)
|
||||||
EmitWaterPolys (s);
|
EmitWaterPolys (s);
|
||||||
|
@ -919,7 +765,6 @@ void DrawTextureChains (void)
|
||||||
|
|
||||||
if (skychain)
|
if (skychain)
|
||||||
{
|
{
|
||||||
R_DrawSkyChain(skychain);
|
|
||||||
skychain = NULL;
|
skychain = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,17 +779,17 @@ void DrawTextureChains (void)
|
||||||
s = t->texturechain;
|
s = t->texturechain;
|
||||||
if (!s)
|
if (!s)
|
||||||
continue;
|
continue;
|
||||||
if (i == skytexturenum)
|
/* if (i == skytexturenum)
|
||||||
R_DrawSkyChain (s);
|
R_DrawSkyChain (s);
|
||||||
else if (i == mirrortexturenum && r_mirroralpha->value != 1.0)
|
else*/ if (i == mirrortexturenum && r_mirroralpha->value != 1.0)
|
||||||
{
|
{
|
||||||
R_MirrorChain (s);
|
R_MirrorChain (s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((s->flags & SURF_DRAWTURB) && r_wateralpha->value != 1.0)
|
// if ((s->flags & SURF_DRAWTURB) && r_wateralpha->value != 1.0)
|
||||||
continue; // draw translucent water later
|
// continue; // draw translucent water later
|
||||||
for ( ; s ; s=s->texturechain)
|
for ( ; s ; s=s->texturechain)
|
||||||
R_RenderBrushPoly (s);
|
R_RenderBrushPoly (s);
|
||||||
}
|
}
|
||||||
|
@ -970,7 +815,6 @@ void R_DrawBrushModel (entity_t *e)
|
||||||
qboolean rotated;
|
qboolean rotated;
|
||||||
|
|
||||||
currententity = e;
|
currententity = e;
|
||||||
currenttexture = -1;
|
|
||||||
|
|
||||||
clmodel = e->model;
|
clmodel = e->model;
|
||||||
|
|
||||||
|
@ -1131,10 +975,7 @@ void R_RecursiveWorldNode (mnode_t *node)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dot >= 0)
|
side = dot < 0;
|
||||||
side = 0;
|
|
||||||
else
|
|
||||||
side = 1;
|
|
||||||
|
|
||||||
// recurse down the children, front side first
|
// recurse down the children, front side first
|
||||||
R_RecursiveWorldNode (node->children[side]);
|
R_RecursiveWorldNode (node->children[side]);
|
||||||
|
@ -1150,41 +991,33 @@ void R_RecursiveWorldNode (mnode_t *node)
|
||||||
side = SURF_PLANEBACK;
|
side = SURF_PLANEBACK;
|
||||||
else if (dot > BACKFACE_EPSILON)
|
else if (dot > BACKFACE_EPSILON)
|
||||||
side = 0;
|
side = 0;
|
||||||
|
for ( ; c ; c--, surf++)
|
||||||
{
|
{
|
||||||
for ( ; c ; c--, surf++)
|
if (surf->visframe != r_framecount)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// don't backface underwater surfaces, because they warp
|
||||||
|
if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK))
|
||||||
|
continue; // wrong side
|
||||||
|
|
||||||
|
// if sorting by texture, just store it out
|
||||||
|
if (gl_texsort->value)
|
||||||
{
|
{
|
||||||
if (surf->visframe != r_framecount)
|
if (!mirror
|
||||||
continue;
|
|| surf->texinfo->texture != cl.worldmodel->textures[mirrortexturenum])
|
||||||
|
|
||||||
// don't backface underwater surfaces, because they warp
|
|
||||||
// if ( !(surf->flags & SURF_UNDERWATER) && ( (dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) )
|
|
||||||
// continue; // wrong side
|
|
||||||
if ( !(((r_viewleaf->contents==CONTENTS_EMPTY && (surf->flags & SURF_UNDERWATER)) ||
|
|
||||||
(r_viewleaf->contents!=CONTENTS_EMPTY && !(surf->flags & SURF_UNDERWATER)))
|
|
||||||
&& !(surf->flags & SURF_DONTWARP)) && ( (dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) )
|
|
||||||
continue; // wrong side
|
|
||||||
|
|
||||||
// if sorting by texture, just store it out
|
|
||||||
if (gl_texsort->value)
|
|
||||||
{
|
{
|
||||||
if (!mirror
|
surf->texturechain = surf->texinfo->texture->texturechain;
|
||||||
|| surf->texinfo->texture != cl.worldmodel->textures[mirrortexturenum])
|
surf->texinfo->texture->texturechain = surf;
|
||||||
{
|
}
|
||||||
surf->texturechain = surf->texinfo->texture->texturechain;
|
} else if (surf->flags & SURF_DRAWSKY) {
|
||||||
surf->texinfo->texture->texturechain = surf;
|
surf->texturechain = skychain;
|
||||||
}
|
skychain = surf;
|
||||||
} else if (surf->flags & SURF_DRAWSKY) {
|
} else if (surf->flags & SURF_DRAWTURB) {
|
||||||
surf->texturechain = skychain;
|
surf->texturechain = waterchain;
|
||||||
skychain = surf;
|
waterchain = surf;
|
||||||
} else if (surf->flags & SURF_DRAWTURB) {
|
} else
|
||||||
surf->texturechain = waterchain;
|
R_DrawSequentialPoly (surf);
|
||||||
waterchain = surf;
|
|
||||||
} else
|
|
||||||
R_DrawSequentialPoly (surf);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// recurse down the back side
|
// recurse down the back side
|
||||||
|
@ -1208,26 +1041,17 @@ void R_DrawWorld (void)
|
||||||
VectorCopy (r_refdef.vieworg, modelorg);
|
VectorCopy (r_refdef.vieworg, modelorg);
|
||||||
|
|
||||||
currententity = &ent;
|
currententity = &ent;
|
||||||
currenttexture = -1;
|
|
||||||
|
|
||||||
glColor3f (1.0, 1.0, 1.0);
|
glColor3f (1.0, 1.0, 1.0);
|
||||||
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
||||||
// Be sure to clear the skybox --KB
|
// Be sure to clear the skybox --KB
|
||||||
R_ClearSkyBox ();
|
R_DrawSky ();
|
||||||
|
|
||||||
R_RecursiveWorldNode (cl.worldmodel->nodes);
|
R_RecursiveWorldNode (cl.worldmodel->nodes);
|
||||||
|
|
||||||
DrawTextureChains ();
|
DrawTextureChains ();
|
||||||
|
|
||||||
R_BlendLightmaps ();
|
R_BlendLightmaps ();
|
||||||
|
|
||||||
// Adjust the depth range and draw the skybox, ensuring it's behind
|
|
||||||
// everhting else. This fixes the problem where some things are
|
|
||||||
// drawn as sky when something else should be drawn. --KB
|
|
||||||
glColor3f (0.5, 0.5, 0.5);
|
|
||||||
glDepthRange (gldepthmax, gldepthmax);
|
|
||||||
R_DrawSkyBox ();
|
|
||||||
glDepthRange (gldepthmin, gldepthmax);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1543,7 +1367,7 @@ void GL_BuildLightmaps (void)
|
||||||
lightmap_rectchange[i].t = BLOCK_HEIGHT;
|
lightmap_rectchange[i].t = BLOCK_HEIGHT;
|
||||||
lightmap_rectchange[i].w = 0;
|
lightmap_rectchange[i].w = 0;
|
||||||
lightmap_rectchange[i].h = 0;
|
lightmap_rectchange[i].h = 0;
|
||||||
GL_Bind(lightmap_textures + i);
|
glBindTexture (GL_TEXTURE_2D, lightmap_textures + i);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes, BLOCK_WIDTH,
|
glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes, BLOCK_WIDTH,
|
||||||
|
|
568
source/gl_warp.c
568
source/gl_warp.c
|
@ -223,7 +223,7 @@ void EmitWaterPolys (msurface_t *fa)
|
||||||
float *v;
|
float *v;
|
||||||
int i;
|
int i;
|
||||||
float s, t, os, ot;
|
float s, t, os, ot;
|
||||||
|
vec3_t nv;
|
||||||
|
|
||||||
for (p=fa->polys ; p ; p=p->next)
|
for (p=fa->polys ; p ; p=p->next)
|
||||||
{
|
{
|
||||||
|
@ -240,80 +240,20 @@ void EmitWaterPolys (msurface_t *fa)
|
||||||
t *= (1.0/64);
|
t *= (1.0/64);
|
||||||
|
|
||||||
glTexCoord2f (s, t);
|
glTexCoord2f (s, t);
|
||||||
glVertex3fv (v);
|
|
||||||
|
VectorCopy (v, nv);
|
||||||
|
nv[2] += r_waterripple->value
|
||||||
|
* turbsin[(int)((v[3]*0.125+realtime) * TURBSCALE) & 255]
|
||||||
|
* turbsin[(int)((v[4]*0.125+realtime) * TURBSCALE) & 255]
|
||||||
|
* (1.0 / 64.0);
|
||||||
|
|
||||||
|
glVertex3fv (nv);
|
||||||
}
|
}
|
||||||
glEnd ();
|
glEnd ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
=============
|
|
||||||
EmitSkyPolys
|
|
||||||
=============
|
|
||||||
*/
|
|
||||||
void EmitSkyPolys (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)
|
|
||||||
{
|
|
||||||
glBegin (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 = dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2];
|
|
||||||
length = sqrt (length);
|
|
||||||
length = 6*63/length;
|
|
||||||
|
|
||||||
dir[0] *= length;
|
|
||||||
dir[1] *= length;
|
|
||||||
|
|
||||||
s = (speedscale + dir[0]) * (1.0/128);
|
|
||||||
t = (speedscale + dir[1]) * (1.0/128);
|
|
||||||
|
|
||||||
glTexCoord2f (s, t);
|
|
||||||
glVertex3fv (v);
|
|
||||||
}
|
|
||||||
glEnd ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
EmitBothSkyLayers
|
|
||||||
|
|
||||||
Does a sky warp on the pre-fragmented glpoly_t chain
|
|
||||||
This will be called for brushmodels, the world
|
|
||||||
will have them chained together.
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
void EmitBothSkyLayers (msurface_t *fa)
|
|
||||||
{
|
|
||||||
GL_DisableMultitexture();
|
|
||||||
|
|
||||||
GL_Bind (solidskytexture);
|
|
||||||
speedscale = realtime*8;
|
|
||||||
speedscale -= (int)speedscale & ~127 ;
|
|
||||||
|
|
||||||
EmitSkyPolys (fa);
|
|
||||||
|
|
||||||
GL_Bind (alphaskytexture);
|
|
||||||
speedscale = realtime*16;
|
|
||||||
speedscale -= (int)speedscale & ~127 ;
|
|
||||||
|
|
||||||
EmitSkyPolys (fa);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================================================================
|
=================================================================
|
||||||
|
|
||||||
|
@ -620,7 +560,7 @@ void R_LoadSkys (char * skyname)
|
||||||
skyloaded = true;
|
skyloaded = true;
|
||||||
for (i=0 ; i<6 ; i++)
|
for (i=0 ; i<6 ; i++)
|
||||||
{
|
{
|
||||||
GL_Bind (SKY_TEX + i);
|
glBindTexture (GL_TEXTURE_2D, SKY_TEX + i);
|
||||||
snprintf (name, sizeof(name),"env/%s%s.tga", skyname, suf[i]);
|
snprintf (name, sizeof(name),"env/%s%s.tga", skyname, suf[i]);
|
||||||
COM_FOpenFile (name, &f);
|
COM_FOpenFile (name, &f);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -630,13 +570,10 @@ void R_LoadSkys (char * skyname)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LoadTGA (f);
|
LoadTGA (f);
|
||||||
// LoadPCX (f);
|
|
||||||
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, targa_rgba);
|
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, targa_rgba);
|
||||||
// glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, pcx_rgb);
|
|
||||||
|
|
||||||
free (targa_rgba);
|
free (targa_rgba);
|
||||||
// free (pcx_rgb);
|
|
||||||
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
@ -646,353 +583,188 @@ void R_LoadSkys (char * skyname)
|
||||||
skyname);
|
skyname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
vec3_t skyclip[6] = {
|
R_SkyBoxPolyVec(vec5_t v)
|
||||||
{1,1,0},
|
|
||||||
{1,-1,0},
|
|
||||||
{0,-1,1},
|
|
||||||
{0,1,1},
|
|
||||||
{1,0,1},
|
|
||||||
{-1,0,1}
|
|
||||||
};
|
|
||||||
int c_sky;
|
|
||||||
|
|
||||||
// 1 = s, 2 = t, 3 = 2048
|
|
||||||
int st_to_vec[6][3] =
|
|
||||||
{
|
{
|
||||||
{3,-1,2},
|
// avoid interpolation seams
|
||||||
{-3,1,2},
|
// s = s * (254.0/256.0) + (1.0/256.0);
|
||||||
|
// t = t * (254.0/256.0) + (1.0/256.0);
|
||||||
|
glTexCoord2fv (v);
|
||||||
|
glVertex3f (r_refdef.vieworg[0] + v[2],
|
||||||
|
r_refdef.vieworg[1] + v[3],
|
||||||
|
r_refdef.vieworg[2] + v[4]);
|
||||||
|
}
|
||||||
|
|
||||||
{1,3,2},
|
#define ftc(x) (x * (254.0/256.0) + (1.0/256.0))
|
||||||
{-1,-3,2},
|
|
||||||
|
|
||||||
{-2,-1,3}, // 0 degrees yaw, look straight up
|
vec5_t skyvec[6][4] = {
|
||||||
{2,-1,-3} // look straight down
|
{
|
||||||
|
// right
|
||||||
// {-1,2,3},
|
{ftc(1), ftc(0), 1024, 1024, 1024},
|
||||||
// {1,2,-3}
|
{ftc(1), ftc(1), 1024, 1024, -1024},
|
||||||
|
{ftc(0), ftc(1), -1024, 1024, -1024},
|
||||||
|
{ftc(0), ftc(0), -1024, 1024, 1024}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// back
|
||||||
|
{ftc(1), ftc(0), -1024, 1024, 1024},
|
||||||
|
{ftc(1), ftc(1), -1024, 1024, -1024},
|
||||||
|
{ftc(0), ftc(1), -1024, -1024, -1024},
|
||||||
|
{ftc(0), ftc(0), -1024, -1024, 1024}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// left
|
||||||
|
{ftc(1), ftc(0), -1024, -1024, 1024},
|
||||||
|
{ftc(1), ftc(1), -1024, -1024, -1024},
|
||||||
|
{ftc(0), ftc(1), 1024, -1024, -1024},
|
||||||
|
{ftc(0), ftc(0), 1024, -1024, 1024}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// front
|
||||||
|
{ftc(1), ftc(0), 1024, -1024, 1024},
|
||||||
|
{ftc(1), ftc(1), 1024, -1024, -1024},
|
||||||
|
{ftc(0), ftc(1), 1024, 1024, -1024},
|
||||||
|
{ftc(0), ftc(0), 1024, 1024, 1024}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// up
|
||||||
|
{ftc(1), ftc(0), 1024, -1024, 1024},
|
||||||
|
{ftc(1), ftc(1), 1024, 1024, 1024},
|
||||||
|
{ftc(0), ftc(1), -1024, 1024, 1024},
|
||||||
|
{ftc(0), ftc(0), -1024, -1024, 1024}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// down
|
||||||
|
{ftc(1), ftc(0), 1024, 1024, -1024},
|
||||||
|
{ftc(1), ftc(1), 1024, -1024, -1024},
|
||||||
|
{ftc(0), ftc(1), -1024, -1024, -1024},
|
||||||
|
{ftc(0), ftc(0), -1024, 1024, -1024}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// s = [0]/[2], t = [1]/[2]
|
#undef ftc
|
||||||
int vec_to_st[6][3] =
|
|
||||||
|
void
|
||||||
|
R_DrawSkyBox (void)
|
||||||
{
|
{
|
||||||
{-2,3,1},
|
int i, j;
|
||||||
{2,3,-1},
|
|
||||||
|
|
||||||
{1,3,2},
|
GL_DisableMultitexture ();
|
||||||
{-1,3,-2},
|
glEnable (GL_DEPTH_TEST);
|
||||||
|
glDepthFunc (GL_ALWAYS);
|
||||||
|
// glDisable (GL_BLEND);
|
||||||
|
// glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
glDepthRange (gldepthmax, gldepthmax);
|
||||||
|
glColor3f (0.5, 0.5, 0.5);
|
||||||
|
|
||||||
{-2,-1,3},
|
for (i = 0; i < 6; i++)
|
||||||
{-2,1,-3}
|
|
||||||
|
|
||||||
// {-1,2,3},
|
|
||||||
// {1,2,-3}
|
|
||||||
};
|
|
||||||
|
|
||||||
float skymins[2][6], skymaxs[2][6];
|
|
||||||
|
|
||||||
void DrawSkyPolygon (int nump, vec3_t vecs)
|
|
||||||
{
|
|
||||||
int i,j;
|
|
||||||
vec3_t v, av;
|
|
||||||
float s, t, dv;
|
|
||||||
int axis;
|
|
||||||
float *vp;
|
|
||||||
|
|
||||||
c_sky++;
|
|
||||||
// decide which face it maps to
|
|
||||||
VectorCopy (vec3_origin, v);
|
|
||||||
for (i=0, vp=vecs ; i<nump ; i++, vp+=3)
|
|
||||||
{
|
{
|
||||||
VectorAdd (vp, v, v);
|
glBindTexture(GL_TEXTURE_2D, SKY_TEX + i);
|
||||||
}
|
glBegin(GL_QUADS);
|
||||||
av[0] = fabs(v[0]);
|
for (j = 0; j < 4; j++)
|
||||||
av[1] = fabs(v[1]);
|
R_SkyBoxPolyVec(skyvec[i][j]);
|
||||||
av[2] = fabs(v[2]);
|
glEnd();
|
||||||
if (av[0] > av[1] && av[0] > av[2])
|
|
||||||
{
|
|
||||||
if (v[0] < 0)
|
|
||||||
axis = 1;
|
|
||||||
else
|
|
||||||
axis = 0;
|
|
||||||
}
|
|
||||||
else if (av[1] > av[2] && av[1] > av[0])
|
|
||||||
{
|
|
||||||
if (v[1] < 0)
|
|
||||||
axis = 3;
|
|
||||||
else
|
|
||||||
axis = 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (v[2] < 0)
|
|
||||||
axis = 5;
|
|
||||||
else
|
|
||||||
axis = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// project new texture coords
|
glColor3f (1,1,1);
|
||||||
for (i=0 ; i<nump ; i++, vecs+=3)
|
glDepthFunc (GL_LEQUAL);
|
||||||
{
|
glEnable (GL_DEPTH_TEST);
|
||||||
j = vec_to_st[axis][2];
|
glDepthRange(gldepthmin, gldepthmax);
|
||||||
if (j > 0)
|
|
||||||
dv = vecs[j - 1];
|
|
||||||
else
|
|
||||||
dv = -vecs[-j - 1];
|
|
||||||
|
|
||||||
j = vec_to_st[axis][0];
|
|
||||||
if (j < 0)
|
|
||||||
s = -vecs[-j -1] / dv;
|
|
||||||
else
|
|
||||||
s = vecs[j-1] / dv;
|
|
||||||
j = vec_to_st[axis][1];
|
|
||||||
if (j < 0)
|
|
||||||
t = -vecs[-j -1] / dv;
|
|
||||||
else
|
|
||||||
t = vecs[j-1] / dv;
|
|
||||||
|
|
||||||
if (s < skymins[0][axis])
|
|
||||||
skymins[0][axis] = s;
|
|
||||||
if (t < skymins[1][axis])
|
|
||||||
skymins[1][axis] = t;
|
|
||||||
if (s > skymaxs[0][axis])
|
|
||||||
skymaxs[0][axis] = s;
|
|
||||||
if (t > skymaxs[1][axis])
|
|
||||||
skymaxs[1][axis] = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MAX_CLIP_VERTS 64
|
|
||||||
void ClipSkyPolygon (int nump, vec3_t vecs, int stage)
|
|
||||||
{
|
|
||||||
float *norm;
|
|
||||||
float *v;
|
|
||||||
qboolean front, back;
|
|
||||||
float d, e;
|
|
||||||
float dists[MAX_CLIP_VERTS];
|
|
||||||
int sides[MAX_CLIP_VERTS];
|
|
||||||
vec3_t newv[2][MAX_CLIP_VERTS];
|
|
||||||
int newc[2];
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
if (nump > MAX_CLIP_VERTS-2)
|
|
||||||
Sys_Error ("ClipSkyPolygon: MAX_CLIP_VERTS");
|
|
||||||
if (stage == 6)
|
|
||||||
{ // fully clipped, so draw it
|
|
||||||
DrawSkyPolygon (nump, vecs);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
front = back = false;
|
|
||||||
norm = skyclip[stage];
|
|
||||||
for (i=0, v = vecs ; i<nump ; i++, v+=3)
|
|
||||||
{
|
|
||||||
d = DotProduct (v, norm);
|
|
||||||
if (d > ON_EPSILON)
|
|
||||||
{
|
|
||||||
front = true;
|
|
||||||
sides[i] = SIDE_FRONT;
|
|
||||||
}
|
|
||||||
else if (d < ON_EPSILON)
|
|
||||||
{
|
|
||||||
back = true;
|
|
||||||
sides[i] = SIDE_BACK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sides[i] = SIDE_ON;
|
|
||||||
dists[i] = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!front || !back)
|
|
||||||
{ // not clipped
|
|
||||||
ClipSkyPolygon (nump, vecs, stage+1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// clip it
|
|
||||||
sides[i] = sides[0];
|
|
||||||
dists[i] = dists[0];
|
|
||||||
VectorCopy (vecs, (vecs+(i*3)) );
|
|
||||||
newc[0] = newc[1] = 0;
|
|
||||||
|
|
||||||
for (i=0, v = vecs ; i<nump ; i++, v+=3)
|
|
||||||
{
|
|
||||||
switch (sides[i])
|
|
||||||
{
|
|
||||||
case SIDE_FRONT:
|
|
||||||
VectorCopy (v, newv[0][newc[0]]);
|
|
||||||
newc[0]++;
|
|
||||||
break;
|
|
||||||
case SIDE_BACK:
|
|
||||||
VectorCopy (v, newv[1][newc[1]]);
|
|
||||||
newc[1]++;
|
|
||||||
break;
|
|
||||||
case SIDE_ON:
|
|
||||||
VectorCopy (v, newv[0][newc[0]]);
|
|
||||||
newc[0]++;
|
|
||||||
VectorCopy (v, newv[1][newc[1]]);
|
|
||||||
newc[1]++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sides[i] == SIDE_ON || sides[i+1] == SIDE_ON || sides[i+1] == sides[i])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
d = dists[i] / (dists[i] - dists[i+1]);
|
|
||||||
for (j=0 ; j<3 ; j++)
|
|
||||||
{
|
|
||||||
e = v[j] + d*(v[j+3] - v[j]);
|
|
||||||
newv[0][newc[0]][j] = e;
|
|
||||||
newv[1][newc[1]][j] = e;
|
|
||||||
}
|
|
||||||
newc[0]++;
|
|
||||||
newc[1]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// continue
|
|
||||||
ClipSkyPolygon (newc[0], newv[0][0], stage+1);
|
|
||||||
ClipSkyPolygon (newc[1], newv[1][0], stage+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
R_DrawSkyChain
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void R_DrawSkyChain (msurface_t *s)
|
|
||||||
{
|
|
||||||
msurface_t *fa;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
vec3_t verts[MAX_CLIP_VERTS];
|
|
||||||
glpoly_t *p;
|
|
||||||
|
|
||||||
if (allowskybox && skyloaded)
|
|
||||||
{
|
|
||||||
c_sky = 0;
|
|
||||||
GL_Bind(solidskytexture);
|
|
||||||
|
|
||||||
// calculate vertex values for sky box
|
|
||||||
|
|
||||||
for (fa=s ; fa ; fa=fa->texturechain)
|
|
||||||
{
|
|
||||||
for (p=fa->polys ; p ; p=p->next)
|
|
||||||
{
|
|
||||||
for (i=0 ; i<p->numverts ; i++)
|
|
||||||
{
|
|
||||||
VectorSubtract (p->verts[i], r_origin, verts[i]);
|
|
||||||
}
|
|
||||||
ClipSkyPolygon (p->numverts, verts[0], 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// skies have no lightmap to prevent overbrighting --KB
|
|
||||||
glColor3f (0.5, 0.5, 0.5);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
GL_Bind (alphaskytexture);
|
|
||||||
speedscale = realtime*16;
|
|
||||||
speedscale -= (int)speedscale & ~127 ;
|
|
||||||
|
|
||||||
for (fa=s ; fa ; fa=fa->texturechain)
|
|
||||||
EmitSkyPolys (fa);
|
|
||||||
|
|
||||||
// the rest of the texture chain does though --KB
|
|
||||||
glColor3f (1.0, 1.0, 1.0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
vec3_t domescale;
|
||||||
==============
|
void
|
||||||
R_ClearSkyBox
|
R_DrawSkyLayer (float s)
|
||||||
==============
|
|
||||||
*/
|
|
||||||
void R_ClearSkyBox (void)
|
|
||||||
{
|
{
|
||||||
int i;
|
float a, b, x, y, a1x, a1y, a2x, a2y;
|
||||||
|
vec3_t v;
|
||||||
for (i=0 ; i<6 ; i++)
|
|
||||||
|
for (a = 0; a < 1; a += (1.0 / 32.0))
|
||||||
{
|
{
|
||||||
skymins[0][i] = skymins[1][i] = 9999;
|
a1x = cos(a * M_PI * 2);
|
||||||
skymaxs[0][i] = skymaxs[1][i] = -9999;
|
a1y = -sin(a * M_PI * 2);
|
||||||
}
|
a2x = cos((a+(1.0/32.0)) * M_PI * 2);
|
||||||
}
|
a2y = -sin((a+(1.0/32.0)) * M_PI * 2);
|
||||||
|
|
||||||
|
glBegin (GL_TRIANGLE_STRIP);
|
||||||
|
for (b = 0; b <= 1; b += (1.0 / 32.0))
|
||||||
|
{
|
||||||
|
x = cos(b * M_PI * 2);
|
||||||
|
y = -sin(b * M_PI * 2);
|
||||||
|
|
||||||
void MakeSkyVec (float s, float t, int axis)
|
v[0] = a1x*x * domescale[0];
|
||||||
{
|
v[1] = a1y*x * domescale[1];
|
||||||
vec3_t v, b;
|
v[2] = y * domescale[2];
|
||||||
int j, k;
|
glTexCoord2f((v[0] + s) * (1.0 / 128.0),
|
||||||
|
(v[1] + s) * (1.0 / 128.0));
|
||||||
|
glVertex3f(v[0] + r_refdef.vieworg[0],
|
||||||
|
v[1] + r_refdef.vieworg[1],
|
||||||
|
v[2] + r_refdef.vieworg[2]);
|
||||||
|
|
||||||
b[0] = s*2048;
|
v[0] = a2x*x * domescale[0];
|
||||||
b[1] = t*2048;
|
v[1] = a2y*x * domescale[1];
|
||||||
b[2] = 2048;
|
v[2] = y * domescale[2];
|
||||||
|
glTexCoord2f((v[0] + s) * (1.0 / 128.0),
|
||||||
for (j=0 ; j<3 ; j++)
|
(v[1] + s) * (1.0 / 128.0));
|
||||||
{
|
glVertex3f(v[0] + r_refdef.vieworg[0],
|
||||||
k = st_to_vec[axis][j];
|
v[1] + r_refdef.vieworg[1],
|
||||||
if (k < 0)
|
v[2] + r_refdef.vieworg[2]);
|
||||||
v[j] = -b[-k - 1];
|
}
|
||||||
else
|
|
||||||
v[j] = b[k - 1];
|
|
||||||
v[j] += r_origin[j];
|
|
||||||
}
|
|
||||||
|
|
||||||
// avoid bilerp seam
|
|
||||||
s = (s+1)*0.5;
|
|
||||||
t = (t+1)*0.5;
|
|
||||||
|
|
||||||
if (s < 1.0/512)
|
|
||||||
s = 1.0/512;
|
|
||||||
else if (s > 511.0/512)
|
|
||||||
s = 511.0/512;
|
|
||||||
if (t < 1.0/512)
|
|
||||||
t = 1.0/512;
|
|
||||||
else if (t > 511.0/512)
|
|
||||||
t = 511.0/512;
|
|
||||||
|
|
||||||
t = 1.0 - t;
|
|
||||||
glTexCoord2f (s, t);
|
|
||||||
glVertex3fv (v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
R_DrawSkyBox
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
int skytexorder[6] = {0,2,1,3,4,5};
|
|
||||||
void R_DrawSkyBox (void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0 ; i<6 ; i++)
|
|
||||||
{
|
|
||||||
if (skymins[0][i] >= skymaxs[0][i]
|
|
||||||
|| skymins[1][i] >= skymaxs[1][i])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
GL_Bind (SKY_TEX+skytexorder[i]);
|
|
||||||
glBegin (GL_QUADS);
|
|
||||||
MakeSkyVec (skymins[0][i], skymins[1][i], i);
|
|
||||||
MakeSkyVec (skymins[0][i], skymaxs[1][i], i);
|
|
||||||
MakeSkyVec (skymaxs[0][i], skymaxs[1][i], i);
|
|
||||||
MakeSkyVec (skymaxs[0][i], skymins[1][i], i);
|
|
||||||
glEnd ();
|
glEnd ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
R_DrawSkyDome (void)
|
||||||
|
{
|
||||||
|
GL_DisableMultitexture ();
|
||||||
|
glEnable (GL_DEPTH_TEST);
|
||||||
|
glDepthFunc (GL_ALWAYS);
|
||||||
|
// glDisable (GL_BLEND);
|
||||||
|
// glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glDepthRange (gldepthmax, gldepthmax);
|
||||||
|
glColor3f (0.5, 0.5, 0.5);
|
||||||
|
|
||||||
|
// base sky
|
||||||
|
glBindTexture (GL_TEXTURE_2D, solidskytexture);
|
||||||
|
domescale[0] = 512;
|
||||||
|
domescale[1] = 512;
|
||||||
|
domescale[2] = 128;
|
||||||
|
speedscale = realtime*8;
|
||||||
|
speedscale -= (int)speedscale & ~127;
|
||||||
|
R_DrawSkyLayer (speedscale);
|
||||||
|
glEnable (GL_BLEND);
|
||||||
|
|
||||||
|
// clouds
|
||||||
|
glBindTexture (GL_TEXTURE_2D, alphaskytexture);
|
||||||
|
domescale[0] = 512;
|
||||||
|
domescale[1] = 512;
|
||||||
|
domescale[2] = 128;
|
||||||
|
speedscale = realtime*16;
|
||||||
|
speedscale -= (int)speedscale & ~127;
|
||||||
|
R_DrawSkyLayer (speedscale);
|
||||||
|
|
||||||
|
// glDisable (GL_BLEND);
|
||||||
|
glColor3f (1,1,1);
|
||||||
|
glDepthFunc (GL_LEQUAL);
|
||||||
|
glEnable (GL_DEPTH_TEST);
|
||||||
|
glDepthRange (gldepthmin, gldepthmax);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
R_DrawSky ( void )
|
||||||
|
{
|
||||||
|
if (skyloaded)
|
||||||
|
R_DrawSkyBox();
|
||||||
|
else
|
||||||
|
R_DrawSkyDome();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===============================================================
|
//===============================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1036,7 +808,7 @@ void R_InitSky (texture_t *mt)
|
||||||
|
|
||||||
if (!solidskytexture)
|
if (!solidskytexture)
|
||||||
solidskytexture = texture_extension_number++;
|
solidskytexture = texture_extension_number++;
|
||||||
GL_Bind (solidskytexture );
|
glBindTexture (GL_TEXTURE_2D, solidskytexture );
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
|
glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
@ -1054,7 +826,7 @@ void R_InitSky (texture_t *mt)
|
||||||
|
|
||||||
if (!alphaskytexture)
|
if (!alphaskytexture)
|
||||||
alphaskytexture = texture_extension_number++;
|
alphaskytexture = texture_extension_number++;
|
||||||
GL_Bind(alphaskytexture);
|
glBindTexture (GL_TEXTURE_2D, alphaskytexture);
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
|
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
|
@ -152,6 +152,8 @@ typedef void (APIENTRY *lp3DFXFUNC) (int, int, int, int, int, const void*);
|
||||||
lp3DFXFUNC glColorTableEXT;
|
lp3DFXFUNC glColorTableEXT;
|
||||||
qboolean is8bit = false;
|
qboolean is8bit = false;
|
||||||
qboolean isPermedia = false;
|
qboolean isPermedia = false;
|
||||||
|
int gl_mtex_enum = TEXTURE0_SGIS;
|
||||||
|
qboolean gl_arb_mtex = false;
|
||||||
qboolean gl_mtexable = false;
|
qboolean gl_mtexable = false;
|
||||||
|
|
||||||
//====================================
|
//====================================
|
||||||
|
@ -517,51 +519,6 @@ void VID_UpdateWindowStatus (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//====================================
|
|
||||||
|
|
||||||
BINDTEXFUNCPTR bindTexFunc;
|
|
||||||
|
|
||||||
#define TEXTURE_EXT_STRING "GL_EXT_texture_object"
|
|
||||||
|
|
||||||
|
|
||||||
void CheckTextureExtensions (void)
|
|
||||||
{
|
|
||||||
char *tmp;
|
|
||||||
qboolean texture_ext;
|
|
||||||
HINSTANCE hInstGL;
|
|
||||||
|
|
||||||
texture_ext = FALSE;
|
|
||||||
/* check for texture extension */
|
|
||||||
tmp = (unsigned char *)glGetString(GL_EXTENSIONS);
|
|
||||||
while (*tmp)
|
|
||||||
{
|
|
||||||
if (strncmp((const char*)tmp, TEXTURE_EXT_STRING, strlen(TEXTURE_EXT_STRING)) == 0)
|
|
||||||
texture_ext = TRUE;
|
|
||||||
tmp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!texture_ext || COM_CheckParm ("-gl11") )
|
|
||||||
{
|
|
||||||
hInstGL = LoadLibrary("opengl32.dll");
|
|
||||||
|
|
||||||
if (hInstGL == NULL)
|
|
||||||
Sys_Error ("Couldn't load opengl32.dll\n");
|
|
||||||
|
|
||||||
bindTexFunc = (void *)GetProcAddress(hInstGL,"glBindTexture");
|
|
||||||
|
|
||||||
if (!bindTexFunc)
|
|
||||||
Sys_Error ("No texture objects!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* load library and get procedure adresses for texture extension API */
|
|
||||||
if ((bindTexFunc = (BINDTEXFUNCPTR)
|
|
||||||
wglGetProcAddress((LPCSTR) "glBindTextureEXT")) == NULL)
|
|
||||||
{
|
|
||||||
Sys_Error ("GetProcAddress for BindTextureEXT failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckArrayExtensions (void)
|
void CheckArrayExtensions (void)
|
||||||
{
|
{
|
||||||
|
@ -612,9 +569,9 @@ void CheckMultiTextureExtensions(void)
|
||||||
{
|
{
|
||||||
Con_Printf ("GL_ARB_multitexture\n");
|
Con_Printf ("GL_ARB_multitexture\n");
|
||||||
qglMTexCoord2f =
|
qglMTexCoord2f =
|
||||||
(void *)wglGetProcAddress("glMTexCoord2fARB");
|
(void *)wglGetProcAddress("glMultiTexCoord2fARB");
|
||||||
qglSelectTexture =
|
qglSelectTexture =
|
||||||
(void *)wglGetProcAddress("glSelectTextureARB");
|
(void *)wglGetProcAddress("glActiveTextureARB");
|
||||||
gl_mtex_enum = GL_TEXTURE0_ARB;
|
gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||||
gl_mtexable = true;
|
gl_mtexable = true;
|
||||||
gl_arb_mtex = true;
|
gl_arb_mtex = true;
|
||||||
|
@ -674,7 +631,6 @@ void GL_Init (void)
|
||||||
if (strnicmp(gl_renderer,"Permedia",8)==0)
|
if (strnicmp(gl_renderer,"Permedia",8)==0)
|
||||||
isPermedia = true;
|
isPermedia = true;
|
||||||
|
|
||||||
CheckTextureExtensions ();
|
|
||||||
CheckMultiTextureExtensions ();
|
CheckMultiTextureExtensions ();
|
||||||
|
|
||||||
glClearColor (0,0,0,0);
|
glClearColor (0,0,0,0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue