mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-29 07:12:30 +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
|
@ -36,9 +36,7 @@
|
||||||
#define WARP_WIDTH 320
|
#define WARP_WIDTH 320
|
||||||
#define WARP_HEIGHT 200
|
#define WARP_HEIGHT 200
|
||||||
|
|
||||||
#ifndef MAX_LBM_HEIGHT // FIXME: get rid of this ifndef --KB
|
|
||||||
#define MAX_LBM_HEIGHT 480
|
#define MAX_LBM_HEIGHT 480
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,9 +118,9 @@ extern PROC glVertexPointerEXT;
|
||||||
// normalizing factor so player model works out to about
|
// normalizing factor so player model works out to about
|
||||||
// 1 pixel per triangle
|
// 1 pixel per triangle
|
||||||
|
|
||||||
#ifndef MAX_LBM_HEIGHT // FIXME: Make this ifndef go away.. --KB
|
|
||||||
#define MAX_LBM_HEIGHT 480
|
#define MAX_LBM_HEIGHT 480
|
||||||
#endif
|
|
||||||
|
#define MAX_GLTEXTURES 2048
|
||||||
|
|
||||||
#define TILE_SIZE 128 // size of textures generated by R_GenTiledSurf
|
#define TILE_SIZE 128 // size of textures generated by R_GenTiledSurf
|
||||||
|
|
||||||
|
@ -215,6 +215,7 @@ extern cvar_t *gl_flashblend;
|
||||||
extern cvar_t *gl_nocolors;
|
extern cvar_t *gl_nocolors;
|
||||||
extern cvar_t *gl_particles;
|
extern cvar_t *gl_particles;
|
||||||
extern cvar_t *gl_fb_models;
|
extern cvar_t *gl_fb_models;
|
||||||
|
extern cvar_t *gl_fb_bmodels;
|
||||||
|
|
||||||
extern int gl_lightmap_format;
|
extern int gl_lightmap_format;
|
||||||
extern int gl_solid_format;
|
extern int gl_solid_format;
|
||||||
|
|
|
@ -92,6 +92,7 @@ typedef struct texture_s
|
||||||
char name[16];
|
char name[16];
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
int gl_texturenum;
|
int gl_texturenum;
|
||||||
|
int gl_fb_texturenum;
|
||||||
struct msurface_s *texturechain; // for gl_texsort drawing
|
struct msurface_s *texturechain; // for gl_texsort drawing
|
||||||
int anim_total; // total tenths in sequence ( 0 = no)
|
int anim_total; // total tenths in sequence ( 0 = no)
|
||||||
int anim_min, anim_max; // time for this frame min <=time< max
|
int anim_min, anim_max; // time for this frame min <=time< max
|
||||||
|
@ -131,6 +132,7 @@ typedef struct glpoly_s
|
||||||
{
|
{
|
||||||
struct glpoly_s *next;
|
struct glpoly_s *next;
|
||||||
struct glpoly_s *chain;
|
struct glpoly_s *chain;
|
||||||
|
struct glpoly_s *fb_chain;
|
||||||
int numverts;
|
int numverts;
|
||||||
int flags; // for SURF_UNDERWATER
|
int flags; // for SURF_UNDERWATER
|
||||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||||
|
|
|
@ -123,7 +123,6 @@ typedef struct
|
||||||
int crc; // not really a standard CRC, but it works
|
int crc; // not really a standard CRC, but it works
|
||||||
} gltexture_t;
|
} gltexture_t;
|
||||||
|
|
||||||
#define MAX_GLTEXTURES 1024
|
|
||||||
static gltexture_t gltextures[MAX_GLTEXTURES];
|
static gltexture_t gltextures[MAX_GLTEXTURES];
|
||||||
static int numgltextures = 0;
|
static int numgltextures = 0;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
#include "quakefs.h"
|
#include "quakefs.h"
|
||||||
#include "glquake.h"
|
#include "glquake.h"
|
||||||
|
|
||||||
|
int Mod_Fullbright(byte *skin, int width, int height, char *name);
|
||||||
|
|
||||||
extern model_t *loadmodel;
|
extern model_t *loadmodel;
|
||||||
extern char loadname[];
|
extern char loadname[];
|
||||||
|
|
||||||
|
@ -48,7 +50,11 @@ const int mod_lightmap_bytes=3;
|
||||||
void
|
void
|
||||||
Mod_ProcessTexture(miptex_t *mt, texture_t *tx)
|
Mod_ProcessTexture(miptex_t *mt, texture_t *tx)
|
||||||
{
|
{
|
||||||
|
char name[32];
|
||||||
|
|
||||||
texture_mode = GL_LINEAR_MIPMAP_NEAREST; //_LINEAR;
|
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);
|
tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false, 1);
|
||||||
texture_mode = GL_LINEAR;
|
texture_mode = GL_LINEAR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,6 +270,8 @@ void R_Init (void)
|
||||||
gl_fb_models = Cvar_Get ("gl_fb_models", "1", CVAR_ARCHIVE,
|
gl_fb_models = Cvar_Get ("gl_fb_models", "1", CVAR_ARCHIVE,
|
||||||
"Toggles fullbright color support for models.. "
|
"Toggles fullbright color support for models.. "
|
||||||
"This is very handy, but costs me 2 FPS.. (=:]");
|
"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_keeptjunctions = Cvar_Get("gl_keeptjunctions", "1", CVAR_NONE, "None");
|
||||||
gl_reporttjunctions = Cvar_Get("gl_reporttjunctions", "0", CVAR_NONE, "None");
|
gl_reporttjunctions = Cvar_Get("gl_reporttjunctions", "0", CVAR_NONE, "None");
|
||||||
|
|
|
@ -79,6 +79,7 @@ typedef struct glRect_s {
|
||||||
} glRect_t;
|
} glRect_t;
|
||||||
|
|
||||||
glpoly_t *lightmap_polys[MAX_LIGHTMAPS];
|
glpoly_t *lightmap_polys[MAX_LIGHTMAPS];
|
||||||
|
glpoly_t *fullbright_polys[MAX_GLTEXTURES];
|
||||||
qboolean lightmap_modified[MAX_LIGHTMAPS];
|
qboolean lightmap_modified[MAX_LIGHTMAPS];
|
||||||
glRect_t lightmap_rectchange[MAX_LIGHTMAPS];
|
glRect_t lightmap_rectchange[MAX_LIGHTMAPS];
|
||||||
|
|
||||||
|
@ -434,6 +435,7 @@ void R_DrawMultitexturePoly (msurface_t *s)
|
||||||
int maps;
|
int maps;
|
||||||
float *v;
|
float *v;
|
||||||
int i;
|
int i;
|
||||||
|
texture_t *texture = R_TextureAnimation (s->texinfo->texture);
|
||||||
|
|
||||||
c_brush_polys++;
|
c_brush_polys++;
|
||||||
|
|
||||||
|
@ -442,7 +444,7 @@ void R_DrawMultitexturePoly (msurface_t *s)
|
||||||
glColor3f(1,1,1);
|
glColor3f(1,1,1);
|
||||||
// Binds world to texture env 0
|
// Binds world to texture env 0
|
||||||
qglSelectTexture (gl_mtex_enum+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);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
// Binds lightmap to texenv 1
|
// Binds lightmap to texenv 1
|
||||||
|
@ -479,6 +481,11 @@ dynamic:
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
qglSelectTexture (gl_mtex_enum+0);
|
qglSelectTexture (gl_mtex_enum+0);
|
||||||
glEnable(GL_TEXTURE_2D);
|
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
|
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
|
R_RenderBrushPoly
|
||||||
|
@ -541,10 +582,11 @@ void R_RenderBrushPoly (msurface_t *fa)
|
||||||
int i;
|
int i;
|
||||||
float *v;
|
float *v;
|
||||||
int smax, tmax;
|
int smax, tmax;
|
||||||
|
texture_t *texture = R_TextureAnimation (fa->texinfo->texture);
|
||||||
|
|
||||||
c_brush_polys++;
|
c_brush_polys++;
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, R_TextureAnimation (fa->texinfo->texture)->gl_texturenum);
|
glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum);
|
||||||
|
|
||||||
glBegin (GL_POLYGON);
|
glBegin (GL_POLYGON);
|
||||||
v = fa->polys->verts[0];
|
v = fa->polys->verts[0];
|
||||||
|
@ -560,6 +602,11 @@ void R_RenderBrushPoly (msurface_t *fa)
|
||||||
fa->polys->chain = lightmap_polys[fa->lightmaptexturenum];
|
fa->polys->chain = lightmap_polys[fa->lightmaptexturenum];
|
||||||
lightmap_polys[fa->lightmaptexturenum] = fa->polys;
|
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
|
// check for lightmap modification
|
||||||
for (maps = 0 ; maps < MAXLIGHTMAPS && fa->styles[maps] != 255 ;
|
for (maps = 0 ; maps < MAXLIGHTMAPS && fa->styles[maps] != 255 ;
|
||||||
maps++)
|
maps++)
|
||||||
|
@ -598,11 +645,14 @@ dynamic:
|
||||||
|
|
||||||
void GL_WaterSurface(msurface_t *s)
|
void GL_WaterSurface(msurface_t *s)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
if (lighthalf)
|
if (lighthalf)
|
||||||
glColor4f(0.5,0.5,0.5, r_wateralpha->value);
|
glColor4f(0.5,0.5,0.5, r_wateralpha->value);
|
||||||
else
|
else
|
||||||
glColor4f(1,1,1, r_wateralpha->value);
|
glColor4f(1,1,1, r_wateralpha->value);
|
||||||
|
i = s->texinfo->texture->gl_texturenum;
|
||||||
|
glBindTexture (GL_TEXTURE_2D, i);
|
||||||
if (r_wateralpha->value < 1.0)
|
if (r_wateralpha->value < 1.0)
|
||||||
{
|
{
|
||||||
glDepthMask(0);
|
glDepthMask(0);
|
||||||
|
@ -721,6 +771,7 @@ void R_DrawBrushModel (entity_t *e)
|
||||||
glColor3f (1, 1, 1);
|
glColor3f (1, 1, 1);
|
||||||
|
|
||||||
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
memset (lightmap_polys, 0, sizeof(lightmap_polys));
|
||||||
|
memset (fullbright_polys, 0, sizeof(fullbright_polys));
|
||||||
|
|
||||||
VectorSubtract (r_refdef.vieworg, e->origin, modelorg);
|
VectorSubtract (r_refdef.vieworg, e->origin, modelorg);
|
||||||
if (rotated)
|
if (rotated)
|
||||||
|
@ -794,6 +845,9 @@ void R_DrawBrushModel (entity_t *e)
|
||||||
if (gl_texsort->value)
|
if (gl_texsort->value)
|
||||||
R_BlendLightmaps ();
|
R_BlendLightmaps ();
|
||||||
|
|
||||||
|
if (gl_fb_bmodels->value)
|
||||||
|
R_RenderFullbrights ();
|
||||||
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -947,6 +1001,7 @@ void R_DrawWorld (void)
|
||||||
|
|
||||||
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));
|
||||||
|
memset (fullbright_polys, 0, sizeof(fullbright_polys));
|
||||||
// Be sure to clear the skybox --KB
|
// Be sure to clear the skybox --KB
|
||||||
R_DrawSky ();
|
R_DrawSky ();
|
||||||
|
|
||||||
|
@ -960,6 +1015,9 @@ void R_DrawWorld (void)
|
||||||
if (gl_texsort->value)
|
if (gl_texsort->value)
|
||||||
R_BlendLightmaps ();
|
R_BlendLightmaps ();
|
||||||
|
|
||||||
|
if (gl_fb_bmodels->value)
|
||||||
|
R_RenderFullbrights ();
|
||||||
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
Loading…
Reference in a new issue