ref: allow to use shortened name when specifying -ref in command line

This commit is contained in:
Alibek Omarov 2019-04-14 22:04:32 +03:00
parent 99478ba9bd
commit d62a12dd9a
2 changed files with 29 additions and 12 deletions

View File

@ -147,7 +147,7 @@ Default build-depended cvar and constant values
#endif #endif
#ifndef DEFAULT_RENDERER #ifndef DEFAULT_RENDERER
#define DEFAULT_RENDERER "ref_gl" #define DEFAULT_RENDERER "gl"
#endif #endif
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE

View File

@ -481,21 +481,38 @@ void R_Shutdown( void )
ref.initialized = false; ref.initialized = false;
} }
void R_GetRendererName( char *dest, size_t size, const char *refdll )
{
Q_snprintf( dest, size, "%sref_%s.%s",
#ifdef OS_LIB_PREFIX
OS_LIB_PREFIX,
#else
"",
#endif
refdll, OS_LIB_EXT );
}
qboolean R_Init( void ) qboolean R_Init( void )
{ {
char refdll[64]; string refopt, refdll;
refdll[0] = 0; if( !Sys_GetParmFromCmdLine( "-ref", refopt ) )
if( !Sys_GetParmFromCmdLine( "-ref", refdll ) )
{ {
Q_snprintf( refdll, sizeof( refdll ), "%s%s.%s", // compile-time defaults
#ifdef OS_LIB_PREFIX R_GetRendererName( refdll, sizeof( refdll ), DEFAULT_RENDERER );
OS_LIB_PREFIX, Con_Printf( "Loading default renderer: %s\n", refdll );
#else }
"", else if( !Q_strstr( refopt, va( ".%s", OS_LIB_EXT ) ) )
#endif {
DEFAULT_RENDERER, OS_LIB_EXT ); // shortened renderer name
R_GetRendererName( refdll, sizeof( refdll ), refopt );
Con_Printf( "Loading renderer by short name: %s\n", refdll );
}
else
{
// full path
Q_strcpy( refdll, refopt );
Con_Printf( "Loading renderer: %s\n", refdll );
} }
gl_vsync = Cvar_Get( "gl_vsync", "0", FCVAR_ARCHIVE, "enable vertical syncronization" ); gl_vsync = Cvar_Get( "gl_vsync", "0", FCVAR_ARCHIVE, "enable vertical syncronization" );