ref: remove shared textures enum, instead use hardcoded texture names

This commit is contained in:
Alibek Omarov 2019-04-15 01:43:43 +03:00
parent 2d968cf328
commit 5be982cc72
9 changed files with 26 additions and 69 deletions

View File

@ -633,7 +633,7 @@ void CL_DrawScreenFade( void )
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
else ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1,
ref.dllFuncs.R_GetBuiltinTexture( REF_WHITE_TEXTURE ));
R_GetBuiltinTexture( REF_WHITE_TEXTURE ));
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}

View File

@ -555,7 +555,7 @@ static void pfnFillRGBA( int x, int y, int width, int height, int r, int g, int
a = bound( 0, a, 255 );
ref.dllFuncs.Color4ub( r, g, b, a );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, ref.dllFuncs.R_GetBuiltinTexture( REF_WHITE_TEXTURE ) );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, R_GetBuiltinTexture( REF_WHITE_TEXTURE ) );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}

View File

@ -2387,8 +2387,8 @@ void Con_VidInit( void )
}
// missed console image will be replaced as gray background like X-Ray or Crysis
if( con.background == ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ) || con.background == 0 )
con.background = ref.dllFuncs.R_GetBuiltinTexture( REF_GRAY_TEXTURE );
if( con.background == R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ) || con.background == 0 )
con.background = R_GetBuiltinTexture( REF_GRAY_TEXTURE );
}
/*

View File

@ -34,8 +34,9 @@ extern ref_globals_t refState;
// handy API wrappers
void R_GetTextureParms( int *w, int *h, int texnum );
#define REF_GET_PARM( parm, arg ) ref.dllFuncs.RefGetParm( (parm), (arg) )
#define GL_LoadTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, false )
#define GL_UpdateTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, true )
#define GL_LoadTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( (name), (pic), (flags), false )
#define GL_UpdateTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( (name), (pic), (flags), true )
#define R_GetBuiltinTexture( name ) ref.dllFuncs.GL_LoadTexture( (name), 0, 0, 0 )
int GL_RenderFrame( const struct ref_viewpass_s *rvp );

View File

@ -1803,8 +1803,8 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
// release old sky layers first
if( !Host_IsDedicated() )
{
ref.dllFuncs.R_FreeSharedTexture( REF_ALPHASKY_TEXTURE );
ref.dllFuncs.R_FreeSharedTexture( REF_SOLIDSKY_TEXTURE );
ref.dllFuncs.GL_FreeTexture( R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ));
ref.dllFuncs.GL_FreeTexture( R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ));
}
#endif
}
@ -1832,7 +1832,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
#ifndef XASH_DEDICATED
if( !Host_IsDedicated() )
{
tx->gl_texturenum = ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE );
tx->gl_texturenum = R_GetBuiltinTexture( REF_DEFAULT_TEXTURE );
tx->width = tx->height = 16;
}
#endif
@ -1882,8 +1882,8 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
{
ref.dllFuncs.R_InitSkyClouds( mt, tx, custom_palette ); // load quake sky
if( ref.dllFuncs.R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) &&
ref.dllFuncs.R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ) )
if( R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) &&
R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ) )
SetBits( world.flags, FWORLD_SKYSPHERE );
continue;
}
@ -1928,7 +1928,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
{
if( host.type != HOST_DEDICATED )
Con_DPrintf( S_ERROR "unable to find %s.mip\n", mt->name );
tx->gl_texturenum = ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE );
tx->gl_texturenum = R_GetBuiltinTexture( REF_DEFAULT_TEXTURE );
}
// check for luma texture

View File

@ -124,14 +124,13 @@ enum // r_speeds counters
RS_ACTIVE_TENTS = 0,
};
enum ref_shared_texture_e
{
REF_DEFAULT_TEXTURE,
REF_GRAY_TEXTURE,
REF_WHITE_TEXTURE,
REF_SOLIDSKY_TEXTURE,
REF_ALPHASKY_TEXTURE,
};
// refdll must expose this default textures using this names
#define REF_DEFAULT_TEXTURE "*default"
#define REF_GRAY_TEXTURE "*gray"
#define REF_WHITE_TEXTURE "*white"
#define REF_BLACK_TEXTURE "*black"
#define REF_SOLIDSKY_TEXTURE "solid_sky"
#define REF_ALPHASKY_TEXTURE "alpha_sky"
typedef enum connstate_e
{
@ -472,8 +471,6 @@ typedef struct ref_interface_s
// texture management
const byte *(*R_GetTextureOriginalBuffer)( unsigned int idx ); // not always available
int (*GL_LoadTextureFromBuffer)( const char *name, rgbdata_t *pic, texFlags_t flags, qboolean update );
int (*R_GetBuiltinTexture)( enum ref_shared_texture_e type );
void (*R_FreeSharedTexture)( enum ref_shared_texture_e type );
void (*GL_ProcessTexture)( int texnum, float gamma, int topColor, int bottomColor );
void (*R_SetupSky)( const char *skyname );

View File

@ -47,45 +47,6 @@ static const byte *R_GetTextureOriginalBuffer( unsigned int idx )
return glt->original->buffer;
}
static int R_GetBuiltinTexture( enum ref_shared_texture_e type )
{
switch( type )
{
case REF_DEFAULT_TEXTURE: return tr.defaultTexture;
case REF_GRAY_TEXTURE: return tr.grayTexture;
case REF_WHITE_TEXTURE: return tr.whiteTexture;
case REF_SOLIDSKY_TEXTURE: return tr.solidskyTexture;
case REF_ALPHASKY_TEXTURE: return tr.alphaskyTexture;
default: gEngfuncs.Host_Error( "R_GetBuiltinTexture: unsupported type %d\n", type );
}
return 0;
}
static void R_FreeSharedTexture( enum ref_shared_texture_e type )
{
int num = 0;
switch( type )
{
case REF_SOLIDSKY_TEXTURE:
num = tr.solidskyTexture;
tr.solidskyTexture = 0;
break;
case REF_ALPHASKY_TEXTURE:
num = tr.alphaskyTexture;
tr.alphaskyTexture = 0;
break;
case REF_DEFAULT_TEXTURE:
case REF_GRAY_TEXTURE:
case REF_WHITE_TEXTURE:
gEngfuncs.Host_Error( "R_FreeSharedTexture: invalid type %d\n", type );
default: gEngfuncs.Host_Error( "R_FreeSharedTexture: unsupported type %d\n", type );
}
GL_FreeTexture( num );
}
/*
=============
CL_FillRGBA
@ -413,8 +374,6 @@ ref_interface_t gReffuncs =
R_GetTextureOriginalBuffer,
GL_LoadTextureFromBuffer,
R_GetBuiltinTexture,
R_FreeSharedTexture,
GL_ProcessTexture,
R_SetupSky,

View File

@ -1910,7 +1910,7 @@ static void GL_CreateInternalTextures( void )
}
}
tr.defaultTexture = GL_LoadTextureInternal( "*default", pic, TF_COLORMAP );
tr.defaultTexture = GL_LoadTextureInternal( REF_DEFAULT_TEXTURE, pic, TF_COLORMAP );
// particle texture from quake1
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA );
@ -1934,19 +1934,19 @@ static void GL_CreateInternalTextures( void )
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFFFFFFFF;
tr.whiteTexture = GL_LoadTextureInternal( "*white", pic, TF_COLORMAP );
tr.whiteTexture = GL_LoadTextureInternal( REF_WHITE_TEXTURE, pic, TF_COLORMAP );
// gray texture
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFF7F7F7F;
tr.grayTexture = GL_LoadTextureInternal( "*gray", pic, TF_COLORMAP );
tr.grayTexture = GL_LoadTextureInternal( REF_GRAY_TEXTURE, pic, TF_COLORMAP );
// black texture
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFF000000;
tr.blackTexture = GL_LoadTextureInternal( "*black", pic, TF_COLORMAP );
tr.blackTexture = GL_LoadTextureInternal( REF_BLACK_TEXTURE, pic, TF_COLORMAP );
// cinematic dummy
pic = GL_FakeImage( 640, 100, 1, IMAGE_HAS_COLOR );

View File

@ -716,7 +716,7 @@ void R_InitSkyClouds( mip_t *mt, texture_t *tx, qboolean custom_palette )
r_temp.palette = NULL;
// load it in
tr.solidskyTexture = GL_LoadTextureInternal( "solid_sky", &r_temp, TF_NOMIPMAP );
tr.solidskyTexture = GL_LoadTextureInternal( REF_SOLIDSKY_TEXTURE, &r_temp, TF_NOMIPMAP );
for( i = 0; i < r_sky->width >> 1; i++ )
{
@ -739,7 +739,7 @@ void R_InitSkyClouds( mip_t *mt, texture_t *tx, qboolean custom_palette )
r_temp.flags = IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA;
// load it in
tr.alphaskyTexture = GL_LoadTextureInternal( "alpha_sky", &r_temp, TF_NOMIPMAP );
tr.alphaskyTexture = GL_LoadTextureInternal( REF_ALPHASKY_TEXTURE, &r_temp, TF_NOMIPMAP );
// clean up
gEngfuncs.FS_FreeImage( r_sky );