18 Oct 2018

This commit is contained in:
g-cont 2018-10-18 00:00:00 +03:00 committed by Alibek Omarov
parent a5b75dd44e
commit 3eb3d161fe
24 changed files with 130 additions and 285 deletions

View File

@ -17,6 +17,7 @@ GNU General Public License for more details.
#define GAMEINFO_H
#define GFL_NOMODELS (1<<0)
#define GFL_NOSKILLS (1<<1)
/*
========================================================================

View File

@ -79,7 +79,7 @@ typedef enum
TF_KEEP_SOURCE = (1<<1), // some images keep source
TF_NOFLIP_TGA = (1<<2), // Steam background completely ignore tga attribute 0x20
TF_EXPAND_SOURCE = (1<<3), // Don't keep source as 8-bit expand to RGBA
// reserved
TF_ALLOW_EMBOSS = (1<<4), // Allow emboss-mapping for this image
TF_RECTANGLE = (1<<5), // this is GL_TEXTURE_RECTANGLE
TF_CUBEMAP = (1<<6), // it's cubemap texture
TF_DEPTHMAP = (1<<7), // custom texture filter used

View File

@ -260,6 +260,8 @@ static void UI_ConvertGameInfo( GAMEINFO *out, gameinfo_t *in )
if( in->nomodels )
out->flags |= GFL_NOMODELS;
if( in->noskills )
out->flags |= GFL_NOSKILLS;
}
static qboolean PIC_Scissor( float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 )
@ -386,7 +388,7 @@ static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, long im
SetBits( flags, TF_IMAGE );
Image_SetForceFlags( IL_LOAD_DECAL ); // allow decal images for menu
tx = GL_LoadTexture( szPicName, image_buf, image_size, flags, NULL );
tx = GL_LoadTexture( szPicName, image_buf, image_size, flags );
Image_ClearForceFlags();
return tx;

View File

@ -126,7 +126,7 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco
memcpy( paletteBackup, pal, 768 );
raw = CL_CreateRawTextureFromPixels( tx, &size, topcolor, bottomcolor );
ptexture->index = GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR, NULL ); // do copy
ptexture->index = GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR ); // do copy
// restore original palette
memcpy( pal, paletteBackup, 768 );

View File

@ -296,7 +296,7 @@ void SCR_DrawPlaque( void )
{
if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
{
int levelshot = GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE, NULL );
int levelshot = GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE );
GL_SetRenderMode( kRenderNormal );
R_DrawStretchPic( 0, 0, glState.width, glState.height, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING );
@ -496,7 +496,7 @@ qboolean SCR_LoadFixedWidthFont( const char *fontname )
if( !FS_FileExists( fontname, false ))
return false;
cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE, NULL );
cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE );
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
cls.creditsFont.charHeight = clgame.scrInfo.iCharHeight = fontWidth / 16;
cls.creditsFont.type = FONT_FIXED;
@ -528,7 +528,7 @@ qboolean SCR_LoadVariableWidthFont( const char *fontname )
if( !FS_FileExists( fontname, false ))
return false;
cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE, NULL );
cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE );
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
// half-life font with variable chars witdh
@ -626,24 +626,24 @@ void SCR_RegisterTextures( void )
// register gfx.wad images
if( FS_FileExists( "gfx/paused.lmp", false ))
cls.pauseIcon = GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE, NULL );
cls.pauseIcon = GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "gfx/pause.lmp", false ))
cls.pauseIcon = GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE, NULL );
cls.pauseIcon = GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
if( FS_FileExists( "gfx/lambda.lmp", false ))
{
if( cl_allow_levelshots->value )
cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE, NULL );
else cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE, NULL );
cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
}
else if( FS_FileExists( "gfx/loading.lmp", false ))
{
if( cl_allow_levelshots->value )
cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE, NULL );
else cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE, NULL );
cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
}
cls.tileImage = GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP, NULL );
cls.tileImage = GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
}
/*

View File

@ -3064,7 +3064,7 @@ int CL_DecalIndex( int id )
if( cl.decal_index[id] == 0 )
{
Image_SetForceFlags( IL_LOAD_DECAL );
cl.decal_index[id] = GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL, NULL );
cl.decal_index[id] = GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
Image_ClearForceFlags();
}

View File

@ -19,6 +19,7 @@ GNU General Public License for more details.
#include "entity_types.h"
#include "gl_local.h"
#include "vgui_draw.h"
#include "sound.h"
/*
===============

View File

@ -536,7 +536,7 @@ qboolean VID_ScreenShot( const char *filename, int shot_type )
break;
}
Image_Process( &r_shot, width, height, flags, NULL );
Image_Process( &r_shot, width, height, flags, 0.0f );
// write image
result = FS_SaveImage( filename, r_shot );
@ -605,7 +605,7 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
r_side->size = r_side->width * r_side->height * 3;
r_side->buffer = temp;
if( flags ) Image_Process( &r_side, 0, 0, flags, NULL );
if( flags ) Image_Process( &r_side, 0, 0, flags, 0.0f );
memcpy( buffer + (size * size * 3 * i), r_side->buffer, size * size * 3 );
}

View File

@ -1208,7 +1208,7 @@ GL_ProcessImage
do specified actions on pixels
===============
*/
static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic, imgfilter_t *filter )
static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic )
{
uint img_flags = 0;
@ -1242,6 +1242,12 @@ static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic, imgfilter_t *fil
tex->flags &= ~TF_MAKELUMA;
}
if( tex->flags & TF_ALLOW_EMBOSS )
{
img_flags |= IMAGE_EMBOSS;
tex->flags &= ~TF_ALLOW_EMBOSS;
}
if( !FBitSet( tex->flags, TF_IMG_UPLOADED ) && FBitSet( tex->flags, TF_KEEP_SOURCE ))
tex->original = FS_CopyImage( pic ); // because current pic will be expanded to rgba
@ -1250,7 +1256,7 @@ static void GL_ProcessImage( gl_texture_t *tex, rgbdata_t *pic, imgfilter_t *fil
img_flags |= IMAGE_FORCE_RGBA;
// processing image before uploading (force to rgba, make luma etc)
if( pic->buffer ) Image_Process( &pic, 0, 0, img_flags, filter );
if( pic->buffer ) Image_Process( &pic, 0, 0, img_flags, gl_emboss_scale->value );
if( FBitSet( tex->flags, TF_LUMINANCE ))
ClearBits( pic->flags, IMAGE_HAS_COLOR );
@ -1421,7 +1427,7 @@ void GL_UpdateTexSize( int texnum, int width, int height, int depth )
GL_LoadTexture
================
*/
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, imgfilter_t *filter )
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags )
{
gl_texture_t *tex;
rgbdata_t *pic;
@ -1448,7 +1454,7 @@ int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, i
// allocate the new one
tex = GL_AllocTexture( name, flags );
GL_ProcessImage( tex, pic, filter );
GL_ProcessImage( tex, pic );
if( !GL_UploadTexture( tex, pic ))
{
@ -1469,7 +1475,7 @@ int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, i
GL_LoadTextureArray
================
*/
int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter )
int GL_LoadTextureArray( const char **names, int flags )
{
rgbdata_t *pic, *src;
char basename[256];
@ -1538,7 +1544,7 @@ int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter )
// but allow to rescale raw images
if( ImageRAW( pic->type ) && ImageRAW( src->type ) && ( pic->width != src->width || pic->height != src->height ))
Image_Process( &src, pic->width, pic->height, IMAGE_RESAMPLE, NULL );
Image_Process( &src, pic->width, pic->height, IMAGE_RESAMPLE, 0.0f );
if( pic->size != src->size )
{
@ -1589,7 +1595,7 @@ int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter )
// allocate the new one
tex = GL_AllocTexture( name, flags );
GL_ProcessImage( tex, pic, filter );
GL_ProcessImage( tex, pic );
if( !GL_UploadTexture( tex, pic ))
{
@ -1636,7 +1642,7 @@ int GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texFlags_t flags
tex = GL_AllocTexture( name, flags );
}
GL_ProcessImage( tex, pic, NULL );
GL_ProcessImage( tex, pic );
if( !GL_UploadTexture( tex, pic ))
{
memset( tex, 0, sizeof( gl_texture_t ));
@ -1828,7 +1834,7 @@ void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
// all the operations makes over the image copy not an original
pic = FS_CopyImage( image->original );
Image_Process( &pic, topColor, bottomColor, flags, NULL );
Image_Process( &pic, topColor, bottomColor, flags, 0.0f );
GL_UploadTexture( image, pic );
GL_ApplyTextureParams( image ); // update texture filter, wrap etc
@ -2185,7 +2191,6 @@ void R_InitImages( void )
R_SetTextureParameters();
GL_CreateInternalTextures();
R_ParseTexFilters( "scripts/texfilter.txt" );
Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
}

View File

@ -309,8 +309,8 @@ void R_SetTextureParameters( void );
gl_texture_t *R_GetTexture( GLenum texnum );
#define GL_LoadTextureInternal( name, pic, flags ) GL_LoadTextureFromBuffer( name, pic, flags, false )
#define GL_UpdateTextureInternal( name, pic, flags ) GL_LoadTextureFromBuffer( name, pic, flags, true )
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, imgfilter_t *filter );
int GL_LoadTextureArray( const char **names, int flags, imgfilter_t *filter );
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags );
int GL_LoadTextureArray( const char **names, int flags );
int GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texFlags_t flags, qboolean update );
byte *GL_ResampleTexture( const byte *source, int in_w, int in_h, int out_w, int out_h, qboolean isNormalMap );
int GL_CreateTexture( const char *name, int width, int height, const void *buffer, texFlags_t flags );
@ -387,8 +387,7 @@ void Matrix4x4_CreateModelview( matrix4x4 out );
//
// gl_rmisc.
//
void R_ParseTexFilters( const char *filename );
imgfilter_t *R_FindTexFilter( const char *texname );
void R_ClearStaticEntities( void );
//
// gl_rsurf.c
@ -469,7 +468,7 @@ void R_Shutdown( void );
qboolean R_Init( void );
void R_Shutdown( void );
void VID_CheckChanges( void );
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags, imgfilter_t *filter );
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags );
void GL_FreeImage( const char *name );
qboolean VID_ScreenShot( const char *filename, int shot_type );
qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot );
@ -642,6 +641,7 @@ extern convar_t *gl_texture_lodbias;
extern convar_t *gl_texture_nearest;
extern convar_t *gl_lightmap_nearest;
extern convar_t *gl_keeptjunctions;
extern convar_t *gl_emboss_scale;
extern convar_t *gl_round_down;
extern convar_t *gl_detailscale;
extern convar_t *gl_wireframe;

View File

@ -1381,16 +1381,6 @@ const byte *GL_TextureData( unsigned int texnum )
return NULL;
}
static int GL_LoadTextureNoFilter( const char *name, const byte *buf, size_t size, int flags )
{
return GL_LoadTexture( name, buf, size, flags, NULL );
}
static int GL_LoadTextureArrayNoFilter( const char **names, int flags )
{
return GL_LoadTextureArray( names, flags, NULL );
}
static const ref_overview_t *GL_GetOverviewParms( void )
{
return &clgame.overView;
@ -1473,9 +1463,9 @@ static render_api_t gRenderAPI =
GL_FindTexture,
GL_TextureName,
GL_TextureData,
GL_LoadTextureNoFilter,
GL_LoadTexture,
GL_CreateTexture,
GL_LoadTextureArrayNoFilter,
GL_LoadTextureArray,
GL_CreateTextureArray,
GL_FreeTexture,
DrawSingleDecal,

View File

@ -19,16 +19,7 @@ GNU General Public License for more details.
#include "mod_local.h"
#include "shake.h"
typedef struct
{
char texname[64]; // shortname
imgfilter_t filter;
} dfilter_t;
dfilter_t *tex_filters[MAX_TEXTURES];
int num_texfilters;
void R_ParseDetailTextures( const char *filename )
static void R_ParseDetailTextures( const char *filename )
{
char *afile, *pfile;
string token, texname;
@ -95,7 +86,7 @@ void R_ParseDetailTextures( const char *filename )
if( Q_stricmp( tex->name, texname ))
continue;
tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR, NULL );
tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR );
// texture is loaded
if( tex->dt_texturenum )
@ -113,110 +104,6 @@ void R_ParseDetailTextures( const char *filename )
Mem_Free( afile );
}
void R_ParseTexFilters( const char *filename )
{
char *afile, *pfile;
string token, texname;
dfilter_t *tf;
int i;
afile = FS_LoadFile( filename, NULL, false );
if( !afile ) return;
pfile = afile;
// format: 'texturename' 'filtername' 'factor' 'bias' 'blendmode' 'grayscale'
while(( pfile = COM_ParseFile( pfile, token )) != NULL )
{
imgfilter_t filter;
memset( &filter, 0, sizeof( filter ));
Q_strncpy( texname, token, sizeof( texname ));
// parse filter
pfile = COM_ParseFile( pfile, token );
if( !Q_stricmp( token, "blur" ))
filter.filter = BLUR_FILTER;
else if( !Q_stricmp( token, "blur2" ))
filter.filter = BLUR_FILTER2;
else if( !Q_stricmp( token, "edge" ))
filter.filter = EDGE_FILTER;
else if( !Q_stricmp( token, "emboss" ))
filter.filter = EMBOSS_FILTER;
// reading factor
pfile = COM_ParseFile( pfile, token );
filter.factor = Q_atof( token );
// reading bias
pfile = COM_ParseFile( pfile, token );
filter.bias = Q_atof( token );
// reading blendFunc
pfile = COM_ParseFile( pfile, token );
if( !Q_stricmp( token, "modulate" ) || !Q_stricmp( token, "GL_MODULATE" ))
filter.blendFunc = GL_MODULATE;
else if( !Q_stricmp( token, "replace" ) || !Q_stricmp( token, "GL_REPLACE" ))
filter.blendFunc = GL_REPLACE;
else if( !Q_stricmp( token, "add" ) || !Q_stricmp( token, "GL_ADD" ))
filter.blendFunc = GL_ADD;
else if( !Q_stricmp( token, "decal" ) || !Q_stricmp( token, "GL_DECAL" ))
filter.blendFunc = GL_DECAL;
else if( !Q_stricmp( token, "blend" ) || !Q_stricmp( token, "GL_BLEND" ))
filter.blendFunc = GL_BLEND;
else if( !Q_stricmp( token, "add_signed" ) || !Q_stricmp( token, "GL_ADD_SIGNED" ))
filter.blendFunc = GL_ADD_SIGNED;
else filter.blendFunc = GL_REPLACE; // defaulting to replace
// reading flags
pfile = COM_ParseFile( pfile, token );
filter.flags = Q_atoi( token );
// make sure what factor is not zeroed
if( filter.factor == 0.0f )
continue;
// check if already existed
for( i = 0; i < num_texfilters; i++ )
{
tf = tex_filters[i];
if( !Q_stricmp( tf->texname, texname ))
break;
}
if( i != num_texfilters )
continue; // already specified
// allocate new texfilter
tf = Z_Malloc( sizeof( dfilter_t ));
tex_filters[num_texfilters++] = tf;
Q_strncpy( tf->texname, texname, sizeof( tf->texname ));
tf->filter = filter;
}
Con_Reportf( "%i texture filters parsed\n", num_texfilters );
Mem_Free( afile );
}
imgfilter_t *R_FindTexFilter( const char *texname )
{
dfilter_t *tf;
int i;
for( i = 0; i < num_texfilters; i++ )
{
tf = tex_filters[i];
if( !Q_stricmp( tf->texname, texname ))
return &tf->filter;
}
return NULL;
}
/*
=======================
R_ClearStaticEntities

View File

@ -69,12 +69,12 @@ static dframetype_t *R_SpriteLoadFrame( model_t *mod, void *pin, mspriteframe_t
if( FBitSet( mod->flags, MODEL_CLIENT )) // it's a HUD sprite
{
Q_snprintf( texname, sizeof( texname ), "#HUD/%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 );
gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags, NULL );
gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags );
}
else
{
Q_snprintf( texname, sizeof( texname ), "#%s(%s:%i%i).spr", sprite_name, group_suffix, num / 10, num % 10 );
gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags, NULL );
gl_texturenum = GL_LoadTexture( texname, pin, pinframe->width * pinframe->height * bytes, r_texFlags );
}
// setup frame description
@ -333,7 +333,7 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean
if( h < MAPSPRITE_SIZE ) h = MAPSPRITE_SIZE;
// resample image if needed
Image_Process( &pix, w, h, IMAGE_FORCE_RGBA|IMAGE_RESAMPLE, NULL );
Image_Process( &pix, w, h, IMAGE_FORCE_RGBA|IMAGE_RESAMPLE, 0.0f );
w = h = MAPSPRITE_SIZE;

View File

@ -3740,7 +3740,6 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
size_t size;
int flags = 0;
char texname[128], name[128], mdlname[128];
imgfilter_t *filter = NULL;
texture_t *tx = NULL;
if( ptexture->flags & STUDIO_NF_NORMALMAP )
@ -3797,10 +3796,6 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
COM_FileBase( ptexture->name, name );
COM_StripExtension( mdlname );
// loading texture filter for studiomodel
if( !FBitSet( ptexture->flags, STUDIO_NF_COLORMAP ))
filter = R_FindTexFilter( va( "%s.mdl/%s", mdlname, name )); // grab texture filter
if( FBitSet( ptexture->flags, STUDIO_NF_NOMIPS ))
SetBits( flags, TF_NOMIPMAP );
@ -3813,7 +3808,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
// build the texname
Q_snprintf( texname, sizeof( texname ), "#%s/%s.mdl", mdlname, name );
ptexture->index = GL_LoadTexture( texname, (byte *)ptexture, size, flags, filter );
ptexture->index = GL_LoadTexture( texname, (byte *)ptexture, size, flags );
if( !ptexture->index )
{

View File

@ -35,6 +35,7 @@ convar_t *gl_texture_nearest;
convar_t *gl_lightmap_nearest;
convar_t *gl_wgl_msaa_samples;
convar_t *gl_keeptjunctions;
convar_t *gl_emboss_scale;
convar_t *gl_showtextures;
convar_t *gl_detailscale;
convar_t *gl_check_errors;
@ -1608,6 +1609,7 @@ void GL_InitCommands( void )
gl_texture_anisotropy = Cvar_Get( "gl_anisotropy", "8", FCVAR_ARCHIVE, "textures anisotropic filter" );
gl_texture_lodbias = Cvar_Get( "gl_texture_lodbias", "0.0", FCVAR_ARCHIVE, "LOD bias for mipmapped textures (perfomance|quality)" );
gl_keeptjunctions = Cvar_Get( "gl_keeptjunctions", "1", FCVAR_ARCHIVE, "removing tjuncs causes blinking pixels" );
gl_emboss_scale = Cvar_Get( "gl_emboss_scale", "0", FCVAR_ARCHIVE|FCVAR_LATCH, "fake bumpmapping scale" );
gl_showtextures = Cvar_Get( "r_showtextures", "0", FCVAR_CHEAT, "show all uploaded textures" );
gl_finish = Cvar_Get( "gl_finish", "0", FCVAR_ARCHIVE, "use glFinish instead of glFlush" );
gl_nosort = Cvar_Get( "gl_nosort", "0", FCVAR_ARCHIVE, "disable sorting of translucent surfaces" );

View File

@ -441,7 +441,7 @@ void R_SetupSky( const char *skyboxname )
Q_snprintf( sidename, sizeof( sidename ), "%s%s", loadname, r_skyBoxSuffix[i] );
else Q_snprintf( sidename, sizeof( sidename ), "%s_%s", loadname, r_skyBoxSuffix[i] );
tr.skyboxTextures[i] = GL_LoadTexture( sidename, NULL, 0, TF_CLAMP|TF_SKY, NULL );
tr.skyboxTextures[i] = GL_LoadTexture( sidename, NULL, 0, TF_CLAMP|TF_SKY );
if( !tr.skyboxTextures[i] ) break;
Con_DPrintf( "%s%s%s", skyboxname, r_skyBoxSuffix[i], i != 5 ? ", " : ". " );
}

View File

@ -228,9 +228,11 @@ typedef struct gameinfo_s
int gamemode;
qboolean secure; // prevent to console acess
qboolean nomodels; // don't let player to choose model (use player.mdl always)
qboolean noskills; // disable skill menu selection
char sp_entity[32]; // e.g. info_player_start
char mp_entity[32]; // e.g. info_player_deathmatch
char mp_filter[32]; // filtering multiplayer-maps
char ambientsound[NUM_AMBIENTS][MAX_QPATH]; // quake ambient sounds
@ -576,7 +578,7 @@ typedef enum
IMAGE_ROT_90 = BIT(18), // flip from upper left corner to down right corner
IMAGE_ROT180 = IMAGE_FLIP_X|IMAGE_FLIP_Y,
IMAGE_ROT270 = IMAGE_FLIP_X|IMAGE_FLIP_Y|IMAGE_ROT_90,
// reserved
IMAGE_EMBOSS = BIT(19), // apply emboss mapping
IMAGE_RESAMPLE = BIT(20), // resample image to specified dims
// reserved
// reserved
@ -587,16 +589,6 @@ typedef enum
IMAGE_REMAP = BIT(27), // interpret width and height as top and bottom color
} imgFlags_t;
// ordering is important!
typedef enum
{
BLUR_FILTER = 0,
BLUR_FILTER2,
EDGE_FILTER,
EMBOSS_FILTER,
NUM_FILTERS,
} pixfilter_t;
typedef struct rgbdata_s
{
word width; // image width
@ -612,21 +604,6 @@ typedef struct rgbdata_s
size_t size; // for bounds checking
} rgbdata_t;
// imgfilter processing flags
typedef enum
{
FILTER_GRAYSCALE = BIT(0),
} flFlags_t;
typedef struct imgfilter_s
{
int filter; // pixfilter_t
float factor; // filter factor value
float bias; // filter bias value
flFlags_t flags; // filter additional flags
uint blendFunc; // blending mode
} imgfilter_t;
//
// imagelib
//
@ -638,7 +615,7 @@ qboolean FS_SaveImage( const char *filename, rgbdata_t *pix );
rgbdata_t *FS_CopyImage( rgbdata_t *in );
void FS_FreeImage( rgbdata_t *pack );
extern const bpc_desc_t PFDesc[]; // image get pixelformat
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgfilter_t *filter );
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float bumpscale );
void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size );
void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size );
void Image_SetForceFlags( uint flags ); // set image force flags on loading

View File

@ -667,7 +667,9 @@ qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
{
qboolean use_filter = false;
byte buf[MAX_SYSPATH];
string mpfilter;
char *buffer;
string result;
int i, size;
@ -677,6 +679,8 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
if( FS_FileSize( "maps.lst", onlyingamedir ) > 0 && !fRefresh )
return true; // exist
// setup mpfilter
Q_snprintf( mpfilter, sizeof( mpfilter ), "maps/%s", GI->mp_filter );
t = FS_Search( "maps/*.bsp", false, onlyingamedir );
if( !t )
@ -690,6 +694,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
}
buffer = Mem_Calloc( host.mempool, t->numfilenames * 2 * sizeof( result ));
use_filter = Q_strlen( GI->mp_filter ) ? true : false;
for( i = 0; i < t->numfilenames; i++ )
{
@ -700,6 +705,9 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "bsp" ))
continue;
if( use_filter && !Q_strnicmp( t->filenames[i], mpfilter, Q_strlen( mpfilter )))
continue;
f = FS_Open( t->filenames[i], "rb", onlyingamedir );
COM_FileBase( t->filenames[i], mapname );
@ -757,7 +765,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
else if( !Q_strcmp( token, "classname" ))
{
pfile = COM_ParseFile( pfile, token );
if( !Q_strcmp( token, GI->mp_entity ))
if( !Q_strcmp( token, GI->mp_entity ) || use_filter )
num_spawnpoints++;
}
if( num_spawnpoints ) break; // valid map

View File

@ -559,7 +559,7 @@ static qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font )
return false;
// keep source to print directly into conback image
font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE, NULL );
font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE );
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );
if( font->hFontTexture && fontWidth != 0 )
@ -595,7 +595,7 @@ static qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font
if( !FS_FileExists( fontname, false ))
return false;
font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST, NULL );
font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST );
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );
// setup consolefont
@ -2340,28 +2340,28 @@ void Con_VidInit( void )
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false ))
con.background = GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE, NULL );
con.background = GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
if( !con.background )
{
if( FS_FileExists( "cached/conback640", false ))
con.background = GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE, NULL );
con.background = GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/conback", false ))
con.background = GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE, NULL );
con.background = GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
}
}
else
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false ))
con.background = GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE, NULL );
con.background = GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
if( !con.background )
{
if( FS_FileExists( "cached/loading640", false ))
con.background = GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE, NULL );
con.background = GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/loading", false ))
con.background = GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE, NULL );
con.background = GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
}
}
@ -2396,13 +2396,13 @@ void Con_VidInit( void )
y = Q_strlen( ver );
for( x = 0; x < y; x++ )
Con_DrawCharToConback( ver[x], chars->original->buffer, dest + (x << 3));
con.background = GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE, NULL );
con.background = GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE );
}
if( cb ) Mem_Free( cb );
}
if( !con.background ) // trying the load unmodified conback
con.background = GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE, NULL );
con.background = GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE );
}
// missed console image will be replaced as gray background like X-Ray or Crysis

View File

@ -848,6 +848,8 @@ static void FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
FS_Printf( f, "sp_entity\t\t\"%s\"\n", GameInfo->sp_entity );
if( Q_strlen( GameInfo->mp_entity ))
FS_Printf( f, "mp_entity\t\t\"%s\"\n", GameInfo->mp_entity );
if( Q_strlen( GameInfo->mp_filter ))
FS_Printf( f, "mp_filter\t\t\"%s\"\n", GameInfo->mp_filter );
if( GameInfo->secure )
FS_Printf( f, "secure\t\t\"%i\"\n", GameInfo->secure );
@ -1031,6 +1033,10 @@ static qboolean FS_ParseLiblistGam( const char *filename, const char *gamedir, g
{
pfile = COM_ParseFile( pfile, GameInfo->mp_entity );
}
else if( !Q_stricmp( token, "mpfilter" ))
{
pfile = COM_ParseFile( pfile, GameInfo->mp_filter );
}
else if( !Q_stricmp( token, "secure" ))
{
pfile = COM_ParseFile( pfile, token );
@ -1137,6 +1143,10 @@ static qboolean FS_ReadGameInfo( const char *filepath, const char *gamedir, game
{
pfile = COM_ParseFile( pfile, GameInfo->mp_entity );
}
else if( !Q_stricmp( token, "mp_filter" ))
{
pfile = COM_ParseFile( pfile, GameInfo->mp_filter );
}
else if( !Q_stricmp( token, "gamedll" ))
{
pfile = COM_ParseFile( pfile, GameInfo->game_dll );
@ -1224,6 +1234,11 @@ static qboolean FS_ReadGameInfo( const char *filepath, const char *gamedir, game
pfile = COM_ParseFile( pfile, token );
GameInfo->nomodels = Q_atoi( token );
}
else if( !Q_stricmp( token, "noskills" ))
{
pfile = COM_ParseFile( pfile, token );
GameInfo->noskills = Q_atoi( token );
}
else if( !Q_strnicmp( token, "ambient", 7 ))
{
int ambientNum = Q_atoi( token + 7 );

View File

@ -81,36 +81,13 @@ static byte palette_hl[768] =
147,255,247,199,255,255,255,159,91,83
};
static float FILTER[NUM_FILTERS][FILTER_SIZE][FILTER_SIZE] =
{
{ // regular blur
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f },
{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f },
{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
},
{ // light blur
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f },
{ 0.0f, 1.0f, 4.0f, 1.0f, 0.0f },
{ 0.0f, 1.0f, 1.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
},
{ // find edges
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, -1.0f, -1.0f, -1.0f, 0.0f },
{ 0.0f, -1.0f, 8.0f, -1.0f, 0.0f },
{ 0.0f, -1.0f, -1.0f, -1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
},
{ // emboss
static float img_emboss[FILTER_SIZE][FILTER_SIZE] =
{
{-0.7f, -0.7f, -0.7f, -0.7f, 0.0f },
{-0.7f, -0.7f, -0.7f, 0.0f, 0.7f },
{-0.7f, -0.7f, 0.0f, 0.7f, 0.7f },
{-0.7f, 0.0f, 0.7f, 0.7f, 0.7f },
{ 0.0f, 0.7f, 0.7f, 0.7f, 0.7f },
}
};
/*
@ -1361,7 +1338,7 @@ Filtering algorithm from http://www.student.kuleuven.ac.be/~m0216922/CG/filterin
All credit due
==================
*/
qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias, flFlags_t flags, GLenum blendFunc )
static void Image_ApplyFilter( rgbdata_t *pic, float factor )
{
int i, x, y;
uint *fin, *fout;
@ -1369,7 +1346,7 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias
// first expand the image into 32-bit buffer
pic = Image_DecompressInternal( pic );
factor = bound( 0.0f, factor, 1.0f );
size = image.width * image.height * 4;
image.tempbuffer = Mem_Realloc( host.imagepool, image.tempbuffer, size );
fout = (uint *)image.tempbuffer;
@ -1381,6 +1358,7 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias
{
vec3_t vout = { 0.0f, 0.0f, 0.0f };
int pos_x, pos_y;
float avg;
for( pos_x = 0; pos_x < FILTER_SIZE; pos_x++ )
{
@ -1391,9 +1369,9 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias
// casting's a unary operation anyway, so the othermost set of brackets in the left part
// of the rvalue should not be necessary... but i'm paranoid when it comes to C...
vout[0] += ((float)((byte *)&fin[img_y * image.width + img_x])[0]) * FILTER[filter][pos_x][pos_y];
vout[1] += ((float)((byte *)&fin[img_y * image.width + img_x])[1]) * FILTER[filter][pos_x][pos_y];
vout[2] += ((float)((byte *)&fin[img_y * image.width + img_x])[2]) * FILTER[filter][pos_x][pos_y];
vout[0] += ((float)((byte *)&fin[img_y * image.width + img_x])[0]) * img_emboss[pos_x][pos_y];
vout[1] += ((float)((byte *)&fin[img_y * image.width + img_x])[1]) * img_emboss[pos_x][pos_y];
vout[2] += ((float)((byte *)&fin[img_y * image.width + img_x])[2]) * img_emboss[pos_x][pos_y];
}
}
@ -1401,20 +1379,17 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias
for( i = 0; i < 3; i++ )
{
vout[i] *= factor;
vout[i] += bias;
vout[i] += 128.0f; // base
vout[i] = bound( 0.0f, vout[i], 255.0f );
}
if( flags & FILTER_GRAYSCALE )
{
// NTSC greyscale conversion standard
float avg = (vout[0] * 30.0f + vout[1] * 59.0f + vout[2] * 11.0f) / 100.0f;
// NTSC greyscale conversion standard
avg = (vout[0] * 30.0f + vout[1] * 59.0f + vout[2] * 11.0f) / 100.0f;
// divide by 255 so GL operations work as expected
vout[0] = avg / 255.0f;
vout[1] = avg / 255.0f;
vout[2] = avg / 255.0f;
}
// divide by 255 so GL operations work as expected
vout[0] = avg / 255.0f;
vout[1] = avg / 255.0f;
vout[2] = avg / 255.0f;
// write to temp - first, write data in (to get the alpha channel quickly and
// easily, which will be left well alone by this particular operation...!)
@ -1429,29 +1404,9 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias
float src = ((float)((byte *)&fin[y * image.width + x])[i]) / 255.0f;
float tmp;
switch( blendFunc )
{
case GL_ADD:
tmp = vout[i] + src;
break;
case GL_BLEND:
// default is FUNC_ADD here
// CsS + CdD works out as Src * Dst * 2
tmp = vout[i] * src * 2.0f;
break;
case GL_DECAL:
// same as GL_REPLACE unless there's alpha, which we ignore for this
case GL_REPLACE:
tmp = vout[i];
break;
case GL_ADD_SIGNED:
tmp = (vout[i] + src) - 0.5f;
break;
case GL_MODULATE:
default: // same as default
tmp = vout[i] * src;
break;
}
// default is GL_BLEND here
// CsS + CdD works out as Src * Dst * 2
tmp = vout[i] * src * 2.0f;
// multiply back by 255 to get the proper byte scale
tmp *= 255.0f;
@ -1466,11 +1421,9 @@ qboolean Image_ApplyFilter( rgbdata_t *pic, int filter, float factor, float bias
// copy result back
memcpy( fin, fout, size );
return true;
}
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgfilter_t *filter )
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float bumpscale )
{
rgbdata_t *pic = *pix;
qboolean result = true;
@ -1483,7 +1436,7 @@ qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgf
return false;
}
if( !flags && !filter )
if( !flags )
{
// clear any force flags
image.force_flags = 0;
@ -1497,7 +1450,7 @@ qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgf
ClearBits( pic->flags, IMAGE_HAS_LUMA );
}
if( flags & IMAGE_REMAP )
if( FBitSet( flags, IMAGE_REMAP ))
{
// NOTE: user should keep copy of indexed image manually for new changes
if( Image_RemapInternal( pic, width, height ))
@ -1505,10 +1458,14 @@ qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, imgf
}
// update format to RGBA if any
if( flags & IMAGE_FORCE_RGBA ) pic = Image_DecompressInternal( pic );
if( flags & IMAGE_LIGHTGAMMA ) pic = Image_LightGamma( pic );
if( FBitSet( flags, IMAGE_FORCE_RGBA ))
pic = Image_DecompressInternal( pic );
if( filter ) Image_ApplyFilter( pic, filter->filter, filter->factor, filter->bias, filter->flags, filter->blendFunc );
if( FBitSet( flags, IMAGE_LIGHTGAMMA ))
pic = Image_LightGamma( pic );
if( FBitSet( flags, IMAGE_EMBOSS ))
Image_ApplyFilter( pic, bumpscale );
out = Image_FlipInternal( pic->buffer, &pic->width, &pic->height, pic->type, flags );
if( pic->buffer != out ) memcpy( pic->buffer, image.tempbuffer, pic->size );

View File

@ -1771,7 +1771,6 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
int num, max, altmax;
qboolean custom_palette;
char texname[64];
imgfilter_t *filter;
mip_t *mt;
int i, j;
@ -1819,7 +1818,6 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
// convert to lowercase
Q_strncpy( tx->name, mt->name, sizeof( tx->name ));
Q_strnlwr( tx->name, tx->name, sizeof( tx->name ));
filter = R_FindTexFilter( tx->name ); // grab texture filter
custom_palette = false;
tx->width = mt->width;
@ -1872,7 +1870,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
if( FS_FileExists( texpath, false ))
{
tx->gl_texturenum = GL_LoadTexture( texpath, NULL, 0, 0, filter );
tx->gl_texturenum = GL_LoadTexture( texpath, NULL, 0, TF_ALLOW_EMBOSS );
bmod->wadlist.wadusage[j]++; // this wad are really used
break;
}
@ -1888,7 +1886,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
if( custom_palette ) size += sizeof( short ) + 768;
Q_snprintf( texname, sizeof( texname ), "#%s:%s.mip", loadstat.name, mt->name );
tx->gl_texturenum = GL_LoadTexture( texname, (byte *)mt, size, 0, filter );
tx->gl_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_ALLOW_EMBOSS );
}
// if texture is completely missed
@ -1911,7 +1909,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
if( custom_palette ) size += sizeof( short ) + 768;
tx->fb_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA, NULL );
tx->fb_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA );
}
else
{
@ -1936,7 +1934,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
}
// okay, loading it from wad or hi-res version
tx->fb_texturenum = GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA, NULL );
tx->fb_texturenum = GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA );
if( src ) Mem_Free( src );
}
}

View File

@ -2106,7 +2106,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
msg_dest = MSG_ALL;
else if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
msg_dest = MSG_ALL;
else msg_dest = MSG_PAS_R;
else msg_dest = (svs.maxclients <= 1 ) ? MSG_ALL : MSG_PAS_R;
// always sending stop sound command
if( FBitSet( flags, SND_STOP ))
@ -2127,7 +2127,7 @@ pfnEmitAmbientSound
*/
void pfnEmitAmbientSound( edict_t *ent, float *pos, const char *sample, float vol, float attn, int flags, int pitch )
{
int msg_dest = MSG_PAS_R;
int msg_dest;
if( sv.state == ss_loading )
SetBits( flags, SND_SPAWNING );

View File

@ -322,6 +322,13 @@ void UI_NewGame_Menu( void )
if( !CheckGameDll( )) return;
// FIXME: show prompt dialog
if( gMenu.m_gameinfo.flags & GFL_NOSKILLS )
{
UI_NewGame_StartGame( 1.0f );
return;
}
UI_NewGame_Precache();
UI_NewGame_Init();