gl_colorlights gone, replaced by gl_lightmap_components. Valid values are 1, 3, 4. 4 (RGBA) default. Significant speedup going from RGB to RGBA on some boards.

Thanks to LordHavoc for the idea, and much of the design.
This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-03-02 23:38:40 +00:00
parent 09f7689a09
commit 6962f954ed
3 changed files with 61 additions and 39 deletions

View file

@ -52,8 +52,7 @@ static int GL_LoadPicTexture (qpic_t *pic, qboolean alpha);
extern byte *host_basepal;
extern unsigned char d_15to8table[65536];
extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor,
*gl_colorlights;
*gl_lightmap_components;
cvar_t *gl_max_size;
cvar_t *gl_picmip;
@ -90,7 +89,7 @@ typedef struct {
float sl, tl, sh, th;
} glpic_t;
int gl_lightmap_format = 4;
int gl_lightmap_format = 4; //FIXME: use GL types? --Despair
int gl_solid_format = 3;
int gl_alpha_format = 4;
@ -395,21 +394,15 @@ Draw_Init_Cvars (void)
{
gl_lightmode = Cvar_Get ("gl_lightmode", "1", CVAR_ARCHIVE,
"Lighting mode (0 = GLQuake style, 1 = new style)");
gl_max_size = Cvar_Get ("gl_max_size", "1024", CVAR_NONE, "Texture dimension");
gl_picmip = Cvar_Get ("gl_picmip", "0", CVAR_NONE, "Dimensions of displayed textures. 0 is normal, 1 is half, 2 is 1/4");
gl_colorlights = Cvar_Get ("gl_colorlights", "1", CVAR_ROM,
"Whether to use RGB lightmaps or not");
gl_constretch = Cvar_Get ("gl_constretch", "0", CVAR_ARCHIVE,
"whether slide the console or stretch it");
gl_conalpha = Cvar_Get ("gl_conalpha", "0.6", CVAR_ARCHIVE,
"alpha value for the console background");
gl_conspin = Cvar_Get ("gl_conspin", "0", CVAR_ARCHIVE,
"speed at which the console spins");
gl_lightmap_components = Cvar_Get ("gl_lightmap_components", "4", CVAR_ROM, "Lightmap texture components. 1 is greyscale, 3 is RGB, 4 is RGBA.");
cl_verstring = Cvar_Get ("cl_verstring", PROGRAM " " VERSION, CVAR_NONE,
"Client version string");
}

View file

@ -51,12 +51,14 @@ qboolean VID_Is8bit (void);
void R_InitBubble (void);
cvar_t *gl_fires;
cvar_t *r_netgraph_alpha;
cvar_t *r_netgraph_box;
extern cvar_t *r_netgraph;
extern cvar_t *gl_lerp_anim;
extern cvar_t *r_netgraph;
qboolean allowskybox; // allow skyboxes? --KB
/*

View file

@ -45,18 +45,19 @@
qboolean r_cache_thrash;
// extern cvar_t *gl_lightmap_align;
cvar_t *gl_lightmap_components;
// extern cvar_t *gl_texsubimage;
extern double realtime;
int skytexturenum;
extern vec3_t shadecolor; // Ender (Extend) Colormod
int lightmap_bytes; // 1 or 3
int lightmap_bytes; // 1, 3, or 4
int lightmap_textures;
unsigned int blocklights[18 * 18 * 3];
cvar_t *gl_colorlights;
#define BLOCK_WIDTH 128
#define BLOCK_HEIGHT 128
@ -235,22 +236,12 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
// set to full bright if no light data
if (!cl.worldmodel->lightdata) {
bl = blocklights;
for (i = 0; i < size; i++) {
*bl++ = 255 << 8;
*bl++ = 255 << 8;
*bl++ = 255 << 8;
}
memset (&blocklights[0], 65280, 3 * size * sizeof(int));
goto store;
}
// clear to no light
bl = blocklights;
for (i = 0; i < size; i++) {
*bl++ = 0;
*bl++ = 0;
*bl++ = 0;
}
bl = blocklights;
memset (&blocklights[0], 0, 3 * size * sizeof(int));
// add all the lightmaps
if (lightmap) {
@ -271,9 +262,37 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
store:
// bound and shift
if (gl_colorlights->int_val) {
stride -= smax * 3;
bl = blocklights;
stride -= smax * lightmap_bytes;
bl = blocklights;
switch (lightmap_bytes) {
case 4:
if (lighthalf) {
for (i = 0; i < tmax; i++, dest += stride) {
for (j = 0; j < smax; j++) {
t = (int) *bl++ >> 8;
*dest++ = bound (0, t, 255);
t = (int) *bl++ >> 8;
*dest++ = bound (0, t, 255);
t = (int) *bl++ >> 8;
*dest++ = bound (0, t, 255);
*dest++ = 255;
}
}
} else {
for (i = 0; i < tmax; i++, dest += stride) {
for (j = 0; j < smax; j++) {
t = (int) *bl++ >> 7;
*dest++ = bound (0, t, 255);
t = (int) *bl++ >> 7;
*dest++ = bound (0, t, 255);
t = (int) *bl++ >> 7;
*dest++ = bound (0, t, 255);
*dest++ = 255;
}
}
}
break;
case 3:
if (lighthalf) {
for (i = 0; i < tmax; i++, dest += stride) {
for (j = 0; j < smax; j++) {
@ -297,9 +316,8 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
}
}
}
} else {
stride -= smax;
bl = blocklights;
break;
case 1:
if (lighthalf) {
for (i = 0; i < tmax; i++, dest += stride) {
for (j = 0; j < smax; j++) {
@ -327,6 +345,7 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
}
}
}
break;
}
}
@ -1028,7 +1047,7 @@ AllocBlock (int w, int h, int *x, int *y)
// LordHavoc: allocate lightmaps only as needed
if (!lightmaps[texnum])
lightmaps[texnum] = calloc (BLOCK_WIDTH * BLOCK_HEIGHT, 3);
lightmaps[texnum] = calloc (BLOCK_WIDTH * BLOCK_HEIGHT, lightmap_bytes); // DESPAIR: was 3, not lightmap_bytes
for (i = 0; i < w; i++)
allocated[texnum][*x + i] = best + h;
@ -1189,12 +1208,20 @@ GL_BuildLightmaps (void)
texture_extension_number += MAX_LIGHTMAPS;
}
if (gl_colorlights->int_val) {
gl_lightmap_format = GL_RGB;
lightmap_bytes = 3;
} else {
switch (gl_lightmap_components->int_val) {
case 1:
gl_lightmap_format = GL_LUMINANCE;
lightmap_bytes = 1;
break;
case 3:
gl_lightmap_format = GL_RGB;
lightmap_bytes = 3;
break;
case 4:
default:
gl_lightmap_format = GL_RGBA;
lightmap_bytes = 4;
break;
}
for (j = 1; j < MAX_MODELS; j++) {