All palettes are gone

This commit is contained in:
cholleme 2003-11-16 22:10:44 +00:00
parent 34530ca6c7
commit c46162e1c1
4 changed files with 55 additions and 443 deletions

View file

@ -563,40 +563,6 @@ void GL_Normalize(byte *in, int width, int height)
}
/*
================
GL_MipMap8Bit
Mipping for 8 bit textures
================
*/
void GL_MipMap8Bit (byte *in, int width, int height)
{
int i, j;
unsigned short r,g,b;
byte *out, *at1, *at2, *at3, *at4;
// width <<=2;
height >>= 1;
out = in;
for (i=0 ; i<height ; i++, in+=width)
{
for (j=0 ; j<width ; j+=2, out+=1, in+=2)
{
at1 = (byte *) (d_8to24table + in[0]);
at2 = (byte *) (d_8to24table + in[1]);
at3 = (byte *) (d_8to24table + in[width+0]);
at4 = (byte *) (d_8to24table + in[width+1]);
r = (at1[0]+at2[0]+at3[0]+at4[0]); r>>=5;
g = (at1[1]+at2[1]+at3[1]+at4[1]); g>>=5;
b = (at1[2]+at2[2]+at3[2]+at4[2]); b>>=5;
out[0] = d_15to8table[(r<<0) + (g<<5) + (b<<10)];
}
}
}
/*
===============
PENTA:
@ -1043,12 +1009,6 @@ void GL_UploadNormal(unsigned int *data, int width, int height, qboolean mipmap)
}
/*
===============
GL_Upload8
===============
*/
//XYZ
unsigned trans[1024*1024]; // FIXME, temporary
static unsigned char glosspix[1024*1024];
static unsigned char detailpix[1024*1024];
@ -1057,220 +1017,6 @@ static unsigned char detailpix[1024*1024];
#define GREEN_MASK 0x0000FF00
#define BLUE_MASK 0x000000FF
void GL_Upload8 (byte *data,char *identifier, int width, int height, qboolean mipmap, qboolean alpha, qboolean bump)
{
//XYZ
static unsigned char bumppix[1024*1024]; // PENTA: bumped texture (it seems the previous one never got fixed anyway)
//static unsigned char glosspix[1024*1024]; // PENTA: bumped texture (it seems the previous one never got fixed anyway)
int i, s;
qboolean noalpha;
int p;
FILE *f;
char filename[MAX_OSPATH];
byte r, g, b;
s = width*height;
//try to load an overrided texture
GL_GetOverrideName(identifier,"",filename);
if ( LoadTextureInPlace(filename, 4, (unsigned char*)&trans[0], &width, &height) )
{
Con_DPrintf("Overriding colormap for %s\n",identifier);
is_overriden = true;
//force it to upload a 32 bit texture
alpha = true;
for (i=0; i<width*height; i++) {
r = (trans[i] & RED_MASK) >> 16;
g = (trans[i] & GREEN_MASK) >> 8;
b = (trans[i] & BLUE_MASK);
bumppix[i] = (r+g+b)/3;
}
}
// if there are no transparent pixels, make it a 3 component
// texture even if it was specified as otherwise
else if (alpha)
{
is_overriden = false;
noalpha = true;
for (i=0 ; i<s ; i++)
{
p = data[i];
if (p == 255)
noalpha = false;
trans[i] = d_8to24table[p];
//PENTA: Grayscale for autobumps
bumppix[i] = d_8to8graytable[p];
}
if (alpha && noalpha)
alpha = false;
}
else
{
is_overriden = false;
if (s&3)
Sys_Error ("GL_Upload8: s&3");
for (i=0 ; i<s ; i+=4)
{
trans[i] = d_8to24table[data[i]];
trans[i+1] = d_8to24table[data[i+1]];
trans[i+2] = d_8to24table[data[i+2]];
trans[i+3] = d_8to24table[data[i+3]];
//PENTA: Grayscale for autobumps
bumppix[i] = d_8to8graytable[data[i]];
bumppix[i+1] = d_8to8graytable[data[i+1]];
bumppix[i+2] = d_8to8graytable[data[i+2]];
bumppix[i+3] = d_8to8graytable[data[i+3]];
}
}
if (!strcmp("scrap",identifier)) {
GL_Upload32 (trans, width, height, mipmap, alpha);
return;
}
//upload color map
GL_Bind(texture_extension_number);
GL_Upload32 (trans, width, height, mipmap, alpha);
texture_extension_number++;
//Disable Bumpmapping parameter and now bumpmap cvar slightly
//works. this only prevents textures from loading, but if it
//has already loaded bumpmaps will not turn off) - Eradicator
if (!COM_CheckParm("-nobumpmaps") && ( sh_bumpmaps.value ) && bump )
{
//upload bump map (if any)
char filename[MAX_OSPATH];
GL_Bind(texture_extension_number);
// first check for normal map
GL_GetOverrideName(identifier,"_norm",filename);
if ( LoadTextureInPlace(filename, 4, (unsigned char*)&trans[0], &width, &height) )
{
char filename[MAX_OSPATH];
int gloss_width, gloss_height;
Con_DPrintf("Overriding normal map for %s\n",identifier);
GL_GetOverrideName(identifier,"_gloss",filename);
if ( LoadTextureInPlace(filename, 1, &glosspix[0], &gloss_width, &gloss_height) )
{
Con_DPrintf("Using gloss map for %s\n",identifier);
}
else
{
//set some gloss by default
gloss_width = width;
gloss_height = height;
Q_memset(&glosspix[0], 255*gl_gloss.value, width*height);
}
if ((gloss_width == width) && (gloss_height == height))
{
GL_PackGloss(glosspix, trans, width*height);
}
else
{
Con_SafePrintf("Error loading gloss map %s: Gloss map bust be the same size as normal map\n", identifier);
}
GL_UploadNormal (trans, width, height, mipmap);
}
else
{
//See if we can override the bump map
GL_GetOverrideName(identifier,"_bump",filename);
//See if we can override the bump map
if ( LoadTextureInPlace(filename, 1, &bumppix[0], &width, &height) )
{
char filename[MAX_OSPATH];
int gloss_width, gloss_height;
Con_DPrintf("Overriding bumpmap for %s\n",identifier);
GL_GetOverrideName(identifier,"_gloss",filename);
if ( LoadTextureInPlace(filename, 1, &glosspix[0], &gloss_width, &gloss_height) )
{
Con_DPrintf("Using gloss map for %s\n",identifier);
}
else
{
//set some gloss by default
gloss_width = width;
gloss_height = height;
Q_memset(&glosspix[0], 255*gl_gloss.value, width*height);
}
if ((gloss_width == width) && (gloss_height == height))
{
}
else
{
Con_SafePrintf("Error loading gloss map %s: Gloss map bust be the same size as bump map\n", identifier);
Q_memset(&glosspix[0], 255*gl_gloss.value, width*height);
}
}
else
{
Q_memset(&glosspix[0], 255*gl_gloss.value, width*height);
}
GL_UploadBump (bumppix, width, height, mipmap, &glosspix[0]);
}
}
texture_extension_number++;
}
/*
================
GL_LoadTexture
================
*//*
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, qboolean bump)
{
int i;
gltexture_t *glt;
// see if the texture is allready present
if (identifier[0])
{
for (i=0, glt=gltextures ; i<numgltextures ; i++, glt++)
{
if (!strcmp (identifier, glt->identifier))
{
if (width != glt->width || height != glt->height)
Con_Printf ("%s: warning: cache mismatch\n",identifier);
//Con_Printf("reuse: %s\n",identifier);
return gltextures[i].texnum;
}
}
}
//else {
glt = &gltextures[numgltextures];
numgltextures++;
//}
//Con_Printf("Load texture: %s %i %i\n",identifier,width,height);
strncpy (glt->identifier, identifier, sizeof(glt->identifier));
glt->texnum = texture_extension_number;
glt->width = width;
glt->height = height;
glt->mipmap = mipmap;
GL_Bind(texture_extension_number );
GL_Upload8 (data, identifier, width, height, mipmap, alpha, bump);
//texture_extension_number++;
return texture_extension_number-2;
}
*/
/*
================
GL_LoadTextureFromFile

18
vid.h
View file

@ -34,9 +34,6 @@ typedef struct vrect_s
typedef struct
{
pixel_t *buffer; // invisible buffer
pixel_t *colormap; // 256 * VID_GRADES size
unsigned short *colormap16; // 256 * VID_GRADES size
int fullbright; // index of first fullbright color
unsigned rowbytes; // may be > width if displayed in a window
unsigned width;
unsigned height;
@ -54,19 +51,8 @@ typedef struct
} viddef_t;
extern viddef_t vid; // global video state
extern unsigned short d_8to16table[256];
extern unsigned d_8to24table[256];
extern unsigned char d_8to8graytable[256];
extern void (*vid_menudrawfn)(void);
extern void (*vid_menukeyfn)(int key);
void VID_SetPalette (unsigned char *palette);
// called at startup and after any gamma correction
void VID_ShiftPalette (unsigned char *palette);
// called for bonus and pain flashes, and for underwater color changes
void VID_Init (unsigned char *palette);
void VID_Init (void);
// Called at startup to set up translation tables, takes 256 8 bit RGB values
// the palette data will go away after the call, so it must be copied off if
// the video driver will need it again
@ -77,7 +63,7 @@ void VID_Shutdown (void);
void VID_Update (vrect_t *rects);
// flushes the given rectangles from the view buffer to the screen
int VID_SetMode (int modenum, unsigned char *palette);
int VID_SetMode (int modenum);
// sets the mode; only used by the Quake engine for resetting to mode 0 (the
// base mode) on memory allocation failures

224
view.c
View file

@ -493,10 +493,7 @@ void V_CalcBlend (void)
{
if (!gl_cshiftpercent.value)
continue;
a2 = (cl.cshifts[j].percent * gl_cshiftpercent.value) * 0.000039215686; //Speedup - Eradicator
// a2 = ((cl.cshifts[j].percent * gl_cshiftpercent.value) / 100.0) / 255.0;
a2 = ((cl.cshifts[j].percent * gl_cshiftpercent.value) / 100.0) / 255.0;
// a2 = cl.cshifts[j].percent/255.0;
if (!a2)
continue;
@ -508,13 +505,9 @@ void V_CalcBlend (void)
b = b*(1-a2) + cl.cshifts[j].destcolor[2]*a2;
}
/*v_blend[0] = r/255.0;
v_blend[0] = r/255.0;
v_blend[1] = g/255.0;
v_blend[2] = b/255.0;*/
v_blend[0] = r*0.0039215686; //Speedup - Eradicator
v_blend[1] = g*0.0039215686;
v_blend[2] = b*0.0039215686;
v_blend[2] = b/255.0;
v_blend[3] = a;
if (v_blend[3] > 1)
v_blend[3] = 1;
@ -523,168 +516,58 @@ void V_CalcBlend (void)
}
#endif
/*
=============
V_UpdatePalette
=============
*/
#ifdef GLQUAKE
void V_UpdatePalette (void)
{
int i, j;
qboolean new;
byte *basepal, *newpal;
byte pal[768];
float r,g,b,a;
int ir, ig, ib;
qboolean force;
/*
=============
V_UpdatePalette
=============
*/
void V_UpdateFlashes (void)
{
int i, j;
qboolean new;
byte *basepal, *newpal;
byte pal[768];
float r,g,b,a;
int ir, ig, ib;
qboolean force;
V_CalcPowerupCshift ();
new = false;
for (i=0 ; i<NUM_CSHIFTS ; i++)
{
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)
{
new = true;
cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
}
for (j=0 ; j<3 ; j++)
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j])
{
new = true;
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
}
}
// drop the damage value
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime*150;
if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0)
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
// drop the bonus value
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime*100;
if (cl.cshifts[CSHIFT_BONUS].percent <= 0)
cl.cshifts[CSHIFT_BONUS].percent = 0;
force = V_CheckGamma ();
if (!new && !force)
return;
//Calculate the color of the polygon to blend
V_CalcBlend ();
V_CalcPowerupCshift ();
new = false;
for (i=0 ; i<NUM_CSHIFTS ; i++)
{
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)
{
new = true;
cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
}
for (j=0 ; j<3 ; j++)
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j])
{
new = true;
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
}
}
// drop the damage value
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime*150;
if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0)
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
// drop the bonus value
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime*100;
if (cl.cshifts[CSHIFT_BONUS].percent <= 0)
cl.cshifts[CSHIFT_BONUS].percent = 0;
force = V_CheckGamma ();
if (!new && !force)
return;
V_CalcBlend ();
a = v_blend[3];
r = 255*v_blend[0]*a;
g = 255*v_blend[1]*a;
b = 255*v_blend[2]*a;
a = 1-a;
for (i=0 ; i<256 ; i++)
{
ir = i*a + r;
ig = i*a + g;
ib = i*a + b;
if (ir > 255)
ir = 255;
if (ig > 255)
ig = 255;
if (ib > 255)
ib = 255;
ramps[0][i] = gammatable[ir];
ramps[1][i] = gammatable[ig];
ramps[2][i] = gammatable[ib];
}
basepal = host_basepal;
newpal = pal;
for (i=0 ; i<256 ; i++)
{
ir = basepal[0];
ig = basepal[1];
ib = basepal[2];
basepal += 3;
newpal[0] = ramps[0][ir];
newpal[1] = ramps[1][ig];
newpal[2] = ramps[2][ib];
newpal += 3;
}
VID_ShiftPalette (pal);
}
#else // !GLQUAKE
void V_UpdatePalette (void)
{
int i, j;
qboolean new;
byte *basepal, *newpal;
byte pal[768];
int r,g,b;
qboolean force;
V_CalcPowerupCshift ();
new = false;
for (i=0 ; i<NUM_CSHIFTS ; i++)
{
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)
{
new = true;
cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
}
for (j=0 ; j<3 ; j++)
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j])
{
new = true;
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
}
}
// drop the damage value
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime*150;
if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0)
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
// drop the bonus value
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime*100;
if (cl.cshifts[CSHIFT_BONUS].percent <= 0)
cl.cshifts[CSHIFT_BONUS].percent = 0;
force = V_CheckGamma ();
if (!new && !force)
return;
basepal = host_basepal;
newpal = pal;
for (i=0 ; i<256 ; i++)
{
r = basepal[0];
g = basepal[1];
b = basepal[2];
basepal += 3;
for (j=0 ; j<NUM_CSHIFTS ; j++)
{
r += (cl.cshifts[j].percent*(cl.cshifts[j].destcolor[0]-r))>>8;
g += (cl.cshifts[j].percent*(cl.cshifts[j].destcolor[1]-g))>>8;
b += (cl.cshifts[j].percent*(cl.cshifts[j].destcolor[2]-b))>>8;
}
newpal[0] = gammatable[r];
newpal[1] = gammatable[g];
newpal[2] = gammatable[b];
newpal += 3;
}
VID_ShiftPalette (pal);
}
#endif // !GLQUAKE
/*
==============================================================================
@ -958,7 +841,6 @@ void V_CalcRefdef (void)
view->model = cl.model_precache[cl.stats[STAT_WEAPON]];
view->frame = cl.stats[STAT_WEAPONFRAME];
view->colormap = vid.colormap;
// set up the refresh position
VectorAdd (r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);

2
view.h
View file

@ -31,5 +31,3 @@ extern cvar_t lcd_x;
void V_Init (void);
void V_RenderView (void);
float V_CalcRoll (vec3_t angles, vec3_t velocity);
void V_UpdatePalette (void);