mirror of
https://git.code.sf.net/p/quake/nuq
synced 2024-11-25 05:21:41 +00:00
brush model fullbrights are now implemented and seem to be working. They can
be toggled using gl_fb_bmodels (default on).
This commit is contained in:
parent
4b67ed54c4
commit
7f785632c0
7 changed files with 66 additions and 4 deletions
|
@ -204,6 +204,7 @@ extern cvar_t *gl_subdivide_size;
|
|||
extern cvar_t *gl_particles;
|
||||
extern cvar_t *gl_fires;
|
||||
extern cvar_t *gl_fb_models;
|
||||
extern cvar_t *gl_fb_bmodels;
|
||||
|
||||
extern int gl_lightmap_format;
|
||||
extern int gl_solid_format;
|
||||
|
|
|
@ -92,11 +92,12 @@ typedef struct texture_s
|
|||
char name[16];
|
||||
unsigned width, height;
|
||||
int gl_texturenum;
|
||||
int gl_fb_texturenum;
|
||||
struct msurface_s *texturechain; // for gl_texsort drawing
|
||||
int anim_total; // total tenths in sequence ( 0 = no)
|
||||
int anim_min, anim_max; // time for this frame min <=time< max
|
||||
struct texture_s *anim_next; // in the animation sequence
|
||||
struct texture_s *alternate_anims; // bmodels in frmae 1 use these
|
||||
struct texture_s *alternate_anims; // bmodels in frame 1 use these
|
||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||
} texture_t;
|
||||
|
||||
|
@ -131,6 +132,7 @@ typedef struct glpoly_s
|
|||
{
|
||||
struct glpoly_s *next;
|
||||
struct glpoly_s *chain;
|
||||
struct glpoly_s *fb_chain;
|
||||
int numverts;
|
||||
int flags; // for SURF_UNDERWATER
|
||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||
|
|
|
@ -154,7 +154,7 @@ void *Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum, qboolean group
|
|||
snprintf(name, sizeof(name), "fb_%s_%i", loadmodel->name,snum);
|
||||
}
|
||||
fbtexnum = Mod_Fullbright(skin+1, pheader->mdl.skinwidth, pheader->mdl.skinheight, name);
|
||||
if ((loadmodel->hasfullbrights=(fbtexnum!=-1))) {
|
||||
if ((loadmodel->hasfullbrights=(fbtexnum))) {
|
||||
pheader->gl_fb_texturenum[snum][gnum] = fbtexnum;
|
||||
}
|
||||
if (group) {
|
||||
|
|
|
@ -45,12 +45,18 @@ extern model_t *loadmodel;
|
|||
extern byte mod_novis[];
|
||||
extern byte *mod_base;
|
||||
|
||||
int Mod_Fullbright(byte *skin, int width, int height, char *name);
|
||||
|
||||
const int mod_lightmap_bytes = 3;
|
||||
|
||||
void
|
||||
Mod_ProcessTexture(miptex_t *mt, texture_t *tx)
|
||||
{
|
||||
char name[32];
|
||||
|
||||
texture_mode = GL_LINEAR_MIPMAP_NEAREST; //_LINEAR;
|
||||
snprintf (name, sizeof(name), "fb_%s", mt->name);
|
||||
tx->gl_fb_texturenum = Mod_Fullbright ((byte *)(tx+1), tx->width, tx->height, name);
|
||||
tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false, 1);
|
||||
texture_mode = GL_LINEAR;
|
||||
}
|
||||
|
|
|
@ -75,5 +75,5 @@ int Mod_Fullbright (byte *skin, int width, int height, char *name)
|
|||
free(ptexels);
|
||||
return texnum;
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -270,6 +270,8 @@ void R_Init (void)
|
|||
gl_fb_models = Cvar_Get ("gl_fb_models", "1", CVAR_ARCHIVE,
|
||||
"Toggles fullbright color support for models.. "
|
||||
"This is very handy, but costs me 2 FPS.. (=:]");
|
||||
gl_fb_bmodels = Cvar_Get ("gl_fb_bmodels", "1", CVAR_ARCHIVE,
|
||||
"Toggles fullbright color support for bmodels");
|
||||
|
||||
gl_keeptjunctions = Cvar_Get("gl_keeptjunctions", "1", CVAR_NONE, "None");
|
||||
gl_reporttjunctions = Cvar_Get("gl_reporttjunctions", "0", CVAR_NONE, "None");
|
||||
|
|
|
@ -80,6 +80,7 @@ typedef struct glRect_s {
|
|||
} glRect_t;
|
||||
|
||||
glpoly_t *lightmap_polys[MAX_LIGHTMAPS];
|
||||
glpoly_t *fullbright_polys[MAX_MAP_TEXTURES*2+1];
|
||||
qboolean lightmap_modified[MAX_LIGHTMAPS];
|
||||
glRect_t lightmap_rectchange[MAX_LIGHTMAPS];
|
||||
|
||||
|
@ -529,6 +530,42 @@ void R_BlendLightmaps (void)
|
|||
glDepthMask (1); // back to normal Z buffering
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
R_RenderFullbrights
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
R_RenderFullbrights (void)
|
||||
{
|
||||
int i, j;
|
||||
glpoly_t *p;
|
||||
float *v;
|
||||
|
||||
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glEnable (GL_BLEND);
|
||||
glColor3f(1,1,1);
|
||||
|
||||
for (i=1; i<MAX_MAP_TEXTURES*2+1; i++) {
|
||||
if (!fullbright_polys[i])
|
||||
continue;
|
||||
glBindTexture (GL_TEXTURE_2D, i);
|
||||
for (p=fullbright_polys[i]; p; p=p->fb_chain) {
|
||||
glBegin (GL_POLYGON);
|
||||
for (j=0, v=p->verts[0]; j<p->numverts; j++, v+=VERTEXSIZE) {
|
||||
glTexCoord2fv (&v[3]);
|
||||
glVertex3fv (v);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
glDisable (GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
R_RenderBrushPoly
|
||||
|
@ -542,10 +579,11 @@ void R_RenderBrushPoly (msurface_t *fa)
|
|||
int i;
|
||||
float *v;
|
||||
int smax, tmax;
|
||||
texture_t *texture = R_TextureAnimation (fa->texinfo->texture);
|
||||
|
||||
c_brush_polys++;
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, R_TextureAnimation (fa->texinfo->texture)->gl_texturenum);
|
||||
glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum);
|
||||
|
||||
glBegin (GL_POLYGON);
|
||||
v = fa->polys->verts[0];
|
||||
|
@ -561,6 +599,11 @@ void R_RenderBrushPoly (msurface_t *fa)
|
|||
fa->polys->chain = lightmap_polys[fa->lightmaptexturenum];
|
||||
lightmap_polys[fa->lightmaptexturenum] = fa->polys;
|
||||
|
||||
if (texture->gl_fb_texturenum>0) {
|
||||
fa->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum];
|
||||
fullbright_polys[texture->gl_fb_texturenum] = fa->polys;
|
||||
}
|
||||
|
||||
// check for lightmap modification
|
||||
for (maps = 0 ; maps < MAXLIGHTMAPS && fa->styles[maps] != 255 ;
|
||||
maps++)
|
||||
|
@ -725,6 +768,7 @@ void R_DrawBrushModel (entity_t *e)
|
|||
glColor3f (1, 1, 1);
|
||||
|
||||
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
||||
memset (fullbright_polys, 0, sizeof(fullbright_polys));
|
||||
|
||||
VectorSubtract (r_refdef.vieworg, e->origin, modelorg);
|
||||
if (rotated)
|
||||
|
@ -798,6 +842,9 @@ void R_DrawBrushModel (entity_t *e)
|
|||
if (gl_texsort->value)
|
||||
R_BlendLightmaps ();
|
||||
|
||||
if (gl_fb_bmodels->int_val)
|
||||
R_RenderFullbrights ();
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
@ -951,6 +998,7 @@ void R_DrawWorld (void)
|
|||
|
||||
glColor3f (1.0, 1.0, 1.0);
|
||||
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
||||
memset (fullbright_polys, 0, sizeof(fullbright_polys));
|
||||
// Be sure to clear the skybox --KB
|
||||
R_DrawSky ();
|
||||
|
||||
|
@ -964,6 +1012,9 @@ void R_DrawWorld (void)
|
|||
if (gl_texsort->value)
|
||||
R_BlendLightmaps ();
|
||||
|
||||
if (gl_fb_bmodels->int_val)
|
||||
R_RenderFullbrights ();
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
|
Loading…
Reference in a new issue