From 12146ebd76364f79a8ceaa331b17458037b9c694 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sun, 4 Oct 2009 10:58:42 +0000 Subject: [PATCH] =?UTF-8?q?Und=20OpenGL=20Palette=20raus.=20Kaum=20eine=20?= =?UTF-8?q?Grafikkarte=20hat=20noch=20ne=20Hardwarepalette.=20War=20auch?= =?UTF-8?q?=20nur=20von=20Icculus=20eingef=C3=BCgt=20worden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/refresh/gl_image.c | 149 +++++++------------------------------ src/refresh/gl_rmain.c | 24 ------ src/refresh/gl_rmisc.c | 7 -- src/refresh/gl_warp.c | 3 - src/refresh/header/local.h | 3 - 5 files changed, 26 insertions(+), 160 deletions(-) diff --git a/src/refresh/gl_image.c b/src/refresh/gl_image.c index 0e657c15..69d27809 100644 --- a/src/refresh/gl_image.c +++ b/src/refresh/gl_image.c @@ -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 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); } diff --git a/src/refresh/gl_rmain.c b/src/refresh/gl_rmain.c index 619e2a6c..e2b599e4 100644 --- a/src/refresh/gl_rmain.c +++ b/src/refresh/gl_rmain.c @@ -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); diff --git a/src/refresh/gl_rmisc.c b/src/refresh/gl_rmisc.c index 01ba5f2f..9ffd5a5a 100644 --- a/src/refresh/gl_rmisc.c +++ b/src/refresh/gl_rmisc.c @@ -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(); } diff --git a/src/refresh/gl_warp.c b/src/refresh/gl_warp.c index 0e6091cf..ae9f3615 100644 --- a/src/refresh/gl_warp.c +++ b/src/refresh/gl_warp.c @@ -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); diff --git a/src/refresh/header/local.h b/src/refresh/header/local.h index ef924347..52242418 100644 --- a/src/refresh/header/local.h +++ b/src/refresh/header/local.h @@ -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);