mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-30 16:50:48 +00:00
gl bmodel fullbrights implemented. I hope. I'll find out for sure when I get
home.
This commit is contained in:
parent
96aba78186
commit
ddef594b2e
7 changed files with 74 additions and 8 deletions
|
@ -123,7 +123,6 @@ typedef struct
|
|||
int crc; // not really a standard CRC, but it works
|
||||
} gltexture_t;
|
||||
|
||||
#define MAX_GLTEXTURES 1024
|
||||
static gltexture_t gltextures[MAX_GLTEXTURES];
|
||||
static int numgltextures = 0;
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include "quakefs.h"
|
||||
#include "glquake.h"
|
||||
|
||||
int Mod_Fullbright(byte *skin, int width, int height, char *name);
|
||||
|
||||
extern model_t *loadmodel;
|
||||
extern char loadname[];
|
||||
|
||||
|
@ -48,7 +50,11 @@ 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;
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -79,6 +79,7 @@ typedef struct glRect_s {
|
|||
} glRect_t;
|
||||
|
||||
glpoly_t *lightmap_polys[MAX_LIGHTMAPS];
|
||||
glpoly_t *fullbright_polys[MAX_GLTEXTURES];
|
||||
qboolean lightmap_modified[MAX_LIGHTMAPS];
|
||||
glRect_t lightmap_rectchange[MAX_LIGHTMAPS];
|
||||
|
||||
|
@ -434,6 +435,7 @@ void R_DrawMultitexturePoly (msurface_t *s)
|
|||
int maps;
|
||||
float *v;
|
||||
int i;
|
||||
texture_t *texture = R_TextureAnimation (s->texinfo->texture);
|
||||
|
||||
c_brush_polys++;
|
||||
|
||||
|
@ -442,7 +444,7 @@ void R_DrawMultitexturePoly (msurface_t *s)
|
|||
glColor3f(1,1,1);
|
||||
// Binds world to texture env 0
|
||||
qglSelectTexture (gl_mtex_enum+0);
|
||||
glBindTexture (GL_TEXTURE_2D, R_TextureAnimation (s->texinfo->texture)->gl_texturenum);
|
||||
glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// Binds lightmap to texenv 1
|
||||
|
@ -479,6 +481,11 @@ dynamic:
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
qglSelectTexture (gl_mtex_enum+0);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
if (texture->gl_fb_texturenum>0) {
|
||||
s->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum];
|
||||
fullbright_polys[texture->gl_fb_texturenum] = s->polys;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -528,6 +535,40 @@ 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_REPLACE);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glEnable (GL_BLEND);
|
||||
glColor3f(1,1,1);
|
||||
|
||||
for (i=1; i<MAX_GLTEXTURES; 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
|
||||
|
@ -541,10 +582,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];
|
||||
|
@ -560,6 +602,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++)
|
||||
|
@ -598,11 +645,14 @@ dynamic:
|
|||
|
||||
void GL_WaterSurface(msurface_t *s)
|
||||
{
|
||||
int i;
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
if (lighthalf)
|
||||
glColor4f(0.5,0.5,0.5, r_wateralpha->value);
|
||||
else
|
||||
glColor4f(1,1,1, r_wateralpha->value);
|
||||
i = s->texinfo->texture->gl_texturenum;
|
||||
glBindTexture (GL_TEXTURE_2D, i);
|
||||
if (r_wateralpha->value < 1.0)
|
||||
{
|
||||
glDepthMask(0);
|
||||
|
@ -721,6 +771,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)
|
||||
|
@ -794,6 +845,9 @@ void R_DrawBrushModel (entity_t *e)
|
|||
if (gl_texsort->value)
|
||||
R_BlendLightmaps ();
|
||||
|
||||
if (gl_fb_bmodels->value)
|
||||
R_RenderFullbrights ();
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
@ -947,6 +1001,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 ();
|
||||
|
||||
|
@ -960,6 +1015,9 @@ void R_DrawWorld (void)
|
|||
if (gl_texsort->value)
|
||||
R_BlendLightmaps ();
|
||||
|
||||
if (gl_fb_bmodels->value)
|
||||
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…
Add table
Add a link
Reference in a new issue