Und OpenGL Palette raus. Kaum eine Grafikkarte hat noch ne

Hardwarepalette. War auch nur von Icculus eingefügt worden.
This commit is contained in:
Yamagi Burmeister 2009-10-04 10:58:42 +00:00
parent 6a901a2baa
commit 12146ebd76
5 changed files with 26 additions and 160 deletions

View file

@ -44,29 +44,6 @@ int gl_tex_alpha_format = 4;
int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
int gl_filter_max = GL_LINEAR;
void GL_SetTexturePalette( unsigned palette[256] )
{
int i;
unsigned char temptable[768];
if ( qglColorTableEXT && gl_ext_palettedtexture->value )
{
for ( i = 0; i < 256; i++ )
{
temptable[i*3+0] = ( palette[i] >> 0 ) & 0xff;
temptable[i*3+1] = ( palette[i] >> 8 ) & 0xff;
temptable[i*3+2] = ( palette[i] >> 16 ) & 0xff;
}
qglColorTableEXT( GL_SHARED_TEXTURE_PALETTE_EXT,
GL_RGB,
256,
GL_RGB,
GL_UNSIGNED_BYTE,
temptable );
}
}
void GL_TexEnv( GLenum mode )
{
static int lastmodes[2] = { -1, -1 };
@ -983,24 +960,7 @@ qboolean GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap)
{
if (!mipmap)
{
if ( qglColorTableEXT && gl_ext_palettedtexture->value && samples == gl_solid_format )
{
uploaded_paletted = true;
GL_BuildPalettedTexture( paletted_texture, ( unsigned char * ) data, scaled_width, scaled_height );
qglTexImage2D( GL_TEXTURE_2D,
0,
GL_COLOR_INDEX8_EXT,
scaled_width,
scaled_height,
0,
GL_COLOR_INDEX,
GL_UNSIGNED_BYTE,
paletted_texture );
}
else
{
qglTexImage2D (GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
qglTexImage2D (GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
goto done;
}
memcpy (scaled, data, width*height*4);
@ -1009,25 +969,7 @@ qboolean GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap)
GL_ResampleTexture (data, width, height, scaled, scaled_width, scaled_height);
GL_LightScaleTexture (scaled, scaled_width, scaled_height, !mipmap );
if ( qglColorTableEXT && gl_ext_palettedtexture->value && ( samples == gl_solid_format ) )
{
uploaded_paletted = true;
GL_BuildPalettedTexture( paletted_texture, ( unsigned char * ) scaled, scaled_width, scaled_height );
qglTexImage2D( GL_TEXTURE_2D,
0,
GL_COLOR_INDEX8_EXT,
scaled_width,
scaled_height,
0,
GL_COLOR_INDEX,
GL_UNSIGNED_BYTE,
paletted_texture );
}
else
{
qglTexImage2D( GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled );
}
qglTexImage2D( GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled );
if (mipmap)
{
@ -1044,24 +986,7 @@ qboolean GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap)
if (scaled_height < 1)
scaled_height = 1;
miplevel++;
if ( qglColorTableEXT && gl_ext_palettedtexture->value && samples == gl_solid_format )
{
uploaded_paletted = true;
GL_BuildPalettedTexture( paletted_texture, ( unsigned char * ) scaled, scaled_width, scaled_height );
qglTexImage2D( GL_TEXTURE_2D,
miplevel,
GL_COLOR_INDEX8_EXT,
scaled_width,
scaled_height,
0,
GL_COLOR_INDEX,
GL_UNSIGNED_BYTE,
paletted_texture );
}
else
{
qglTexImage2D (GL_TEXTURE_2D, miplevel, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
}
qglTexImage2D (GL_TEXTURE_2D, miplevel, comp, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
}
}
done: ;
@ -1099,55 +1024,33 @@ qboolean GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboole
if (s > sizeof(trans)/4)
ri.Sys_Error (ERR_DROP, "GL_Upload8: too large");
if ( qglColorTableEXT &&
gl_ext_palettedtexture->value &&
is_sky )
for (i=0 ; i<s ; i++)
{
qglTexImage2D( GL_TEXTURE_2D,
0,
GL_COLOR_INDEX8_EXT,
width,
height,
0,
GL_COLOR_INDEX,
GL_UNSIGNED_BYTE,
data );
p = data[i];
trans[i] = d_8to24table[p];
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
return false; // SBF: FIXME - what is the correct return value?
}
else
{
for (i=0 ; i<s ; i++)
{
p = data[i];
trans[i] = d_8to24table[p];
if (p == 255)
{ // transparent, so scan around for another color
// to avoid alpha fringes
// FIXME: do a full flood fill so mips work...
if (i > width && data[i-width] != 255)
p = data[i-width];
else if (i < s-width && data[i+width] != 255)
p = data[i+width];
else if (i > 0 && data[i-1] != 255)
p = data[i-1];
else if (i < s-1 && data[i+1] != 255)
p = data[i+1];
else
p = 0;
// copy rgb components
((byte *)&trans[i])[0] = ((byte *)&d_8to24table[p])[0];
((byte *)&trans[i])[1] = ((byte *)&d_8to24table[p])[1];
((byte *)&trans[i])[2] = ((byte *)&d_8to24table[p])[2];
}
if (p == 255)
{ // transparent, so scan around for another color
// to avoid alpha fringes
// FIXME: do a full flood fill so mips work...
if (i > width && data[i-width] != 255)
p = data[i-width];
else if (i < s-width && data[i+width] != 255)
p = data[i+width];
else if (i > 0 && data[i-1] != 255)
p = data[i-1];
else if (i < s-1 && data[i+1] != 255)
p = data[i+1];
else
p = 0;
// copy rgb components
((byte *)&trans[i])[0] = ((byte *)&d_8to24table[p])[0];
((byte *)&trans[i])[1] = ((byte *)&d_8to24table[p])[1];
((byte *)&trans[i])[2] = ((byte *)&d_8to24table[p])[2];
}
return GL_Upload32 (trans, width, height, mipmap);
}
return GL_Upload32 (trans, width, height, mipmap);
}

View file

@ -95,8 +95,6 @@ cvar_t *gl_particle_att_b;
cvar_t *gl_particle_att_c;
cvar_t *gl_ext_swapinterval;
cvar_t *gl_ext_palettedtexture;
cvar_t *gl_ext_multitexture;
cvar_t *gl_ext_pointparameters;
cvar_t *gl_ext_compiled_vertex_array;
@ -947,8 +945,6 @@ void R_Register( void )
gl_vertex_arrays = ri.Cvar_Get( "gl_vertex_arrays", "0", CVAR_ARCHIVE );
gl_ext_swapinterval = ri.Cvar_Get( "gl_ext_swapinterval", "1", CVAR_ARCHIVE );
gl_ext_palettedtexture = ri.Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE );
gl_ext_multitexture = ri.Cvar_Get( "gl_ext_multitexture", "1", CVAR_ARCHIVE );
gl_ext_pointparameters = ri.Cvar_Get( "gl_ext_pointparameters", "1", CVAR_ARCHIVE );
gl_ext_compiled_vertex_array = ri.Cvar_Get( "gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE );
@ -1190,25 +1186,6 @@ int R_Init( void *hinstance, void *hWnd )
ri.Con_Printf( PRINT_ALL, "...GL_EXT_point_parameters not found\n" );
}
if ( !qglColorTableEXT &&
strstr( gl_config.extensions_string, "GL_EXT_paletted_texture" ) &&
strstr( gl_config.extensions_string, "GL_EXT_shared_texture_palette" ) )
{
if ( gl_ext_palettedtexture->value )
{
ri.Con_Printf( PRINT_ALL, "...using GL_EXT_shared_texture_palette\n" );
qglColorTableEXT = ( void ( APIENTRY * ) ( GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid * ) ) qwglGetProcAddress( "glColorTableEXT" );
}
else
{
ri.Con_Printf( PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n" );
}
}
else
{
ri.Con_Printf( PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n" );
}
GL_SetDefaultState();
GL_InitImages ();
@ -1407,7 +1384,6 @@ void R_SetPalette ( const unsigned char *palette)
rp[i*4+3] = 0xff;
}
}
GL_SetTexturePalette( r_rawpalette );
qglClearColor (0,0,0,0);
qglClear (GL_COLOR_BUFFER_BIT);

View file

@ -219,13 +219,6 @@ void GL_SetDefaultState( void )
qglPointParameterfvEXT( GL_DISTANCE_ATTENUATION_EXT, attenuations );
}
if ( qglColorTableEXT && gl_ext_palettedtexture->value )
{
qglEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
GL_SetTexturePalette( d_8to24table );
}
GL_UpdateSwapInterval();
}

View file

@ -601,9 +601,6 @@ void R_SetSky (char *name, float rotate, vec3_t axis)
if (gl_skymip->value || skyrotate)
gl_picmip->value++;
if ( qglColorTableEXT && gl_ext_palettedtexture->value )
Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[i]);
else
Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
sky_images[i] = GL_FindImage (pathname, it_sky);

View file

@ -181,7 +181,6 @@ extern cvar_t *r_lightlevel; // FIXME: This is a HACK to get the client's light
extern cvar_t *gl_vertex_arrays;
extern cvar_t *gl_ext_swapinterval;
extern cvar_t *gl_ext_palettedtexture;
extern cvar_t *gl_ext_multitexture;
extern cvar_t *gl_ext_pointparameters;
extern cvar_t *gl_ext_compiled_vertex_array;
@ -317,8 +316,6 @@ image_t *GL_FindImage (char *name, imagetype_t type);
void GL_TextureMode( char *string );
void GL_ImageList_f (void);
void GL_SetTexturePalette( unsigned palette[256] );
void GL_InitImages (void);
void GL_ShutdownImages (void);