mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
engine: implement menu extensions to allow choosing renderers from GUI
This commit is contained in:
parent
a1ae770f70
commit
8323df240b
@ -1185,12 +1185,27 @@ static void pfnEnableTextInput( int enable )
|
|||||||
Key_EnableTextInput( enable, false );
|
Key_EnableTextInput( enable, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int pfnGetRenderers( unsigned int num, char *shortName, size_t size1, char *readableName, size_t size2 )
|
||||||
|
{
|
||||||
|
if( num >= ref.numRenderers )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( shortName && size1 )
|
||||||
|
Q_strncpy( shortName, ref.shortNames[num], size1 );
|
||||||
|
|
||||||
|
if( readableName && size2 )
|
||||||
|
Q_strncpy( readableName, ref.readableNames[num], size2 );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static ui_extendedfuncs_t gExtendedfuncs =
|
static ui_extendedfuncs_t gExtendedfuncs =
|
||||||
{
|
{
|
||||||
pfnEnableTextInput,
|
pfnEnableTextInput,
|
||||||
Con_UtfProcessChar,
|
Con_UtfProcessChar,
|
||||||
Con_UtfMoveLeft,
|
Con_UtfMoveLeft,
|
||||||
Con_UtfMoveRight
|
Con_UtfMoveRight,
|
||||||
|
pfnGetRenderers
|
||||||
};
|
};
|
||||||
|
|
||||||
void UI_UnloadProgs( void )
|
void UI_UnloadProgs( void )
|
||||||
|
@ -573,9 +573,8 @@ void R_CollectRendererNames( void )
|
|||||||
|
|
||||||
ref.numRenderers = 0;
|
ref.numRenderers = 0;
|
||||||
|
|
||||||
for( i = 0; i < ARRAYSIZE( ref.renderers ); i++ )
|
for( i = 0; i < DEFAULT_RENDERERS_LEN; i++ )
|
||||||
{
|
{
|
||||||
ref_renderer_t *refdll = ref.renderers + ref.numRenderers;
|
|
||||||
string temp;
|
string temp;
|
||||||
void *dll, *pfn;
|
void *dll, *pfn;
|
||||||
|
|
||||||
@ -592,21 +591,21 @@ void R_CollectRendererNames( void )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_strncpy( refdll->shortenedName, renderers[i], sizeof( refdll->shortenedName ));
|
Q_strncpy( ref.shortNames[i], renderers[i], sizeof( ref.shortNames[i] ));
|
||||||
|
|
||||||
pfn = COM_GetProcAddress( dll, GET_REF_HUMANREADABLE_NAME );
|
pfn = COM_GetProcAddress( dll, GET_REF_HUMANREADABLE_NAME );
|
||||||
if( !pfn ) // just in case
|
if( !pfn ) // just in case
|
||||||
{
|
{
|
||||||
Q_strncpy( refdll->humanReadable, renderers[i], sizeof( refdll->humanReadable ));
|
Q_strncpy( ref.readableNames[i], renderers[i], sizeof( ref.readableNames[i] ));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
REF_HUMANREADABLE_NAME GetHumanReadableName = (REF_HUMANREADABLE_NAME)pfn;
|
REF_HUMANREADABLE_NAME GetHumanReadableName = (REF_HUMANREADABLE_NAME)pfn;
|
||||||
|
|
||||||
GetHumanReadableName( refdll->humanReadable, sizeof( refdll->humanReadable ));
|
GetHumanReadableName( ref.readableNames[i], sizeof( ref.readableNames[i] ));
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "Found renderer %s: %s\n", refdll->shortenedName, refdll->humanReadable );
|
Con_Printf( "Found renderer %s: %s\n", ref.shortNames[i], ref.readableNames[i] );
|
||||||
|
|
||||||
ref.numRenderers++;
|
ref.numRenderers++;
|
||||||
COM_FreeLibrary( dll );
|
COM_FreeLibrary( dll );
|
||||||
|
@ -20,12 +20,6 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
|
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
|
||||||
|
|
||||||
typedef struct ref_renderer_s
|
|
||||||
{
|
|
||||||
string shortenedName;
|
|
||||||
string humanReadable;
|
|
||||||
} ref_renderer_t;
|
|
||||||
|
|
||||||
struct ref_state_s
|
struct ref_state_s
|
||||||
{
|
{
|
||||||
qboolean initialized;
|
qboolean initialized;
|
||||||
@ -34,7 +28,8 @@ struct ref_state_s
|
|||||||
ref_interface_t dllFuncs;
|
ref_interface_t dllFuncs;
|
||||||
|
|
||||||
int numRenderers;
|
int numRenderers;
|
||||||
ref_renderer_t renderers[DEFAULT_RENDERERS_LEN];
|
string shortNames[DEFAULT_RENDERERS_LEN];
|
||||||
|
string readableNames[DEFAULT_RENDERERS_LEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct ref_state_s ref;
|
extern struct ref_state_s ref;
|
||||||
|
@ -202,6 +202,8 @@ typedef struct ui_extendedfuncs_s {
|
|||||||
int (*pfnUtfMoveRight) ( char *str, int pos, int length );
|
int (*pfnUtfMoveRight) ( char *str, int pos, int length );
|
||||||
|
|
||||||
// new engine extended api start here
|
// new engine extended api start here
|
||||||
|
// returns 1 if there are more in list, otherwise 0
|
||||||
|
int (*pfnGetRenderers)( unsigned int num, char *shortName, size_t size1, char *readableName, size_t size2 );
|
||||||
} ui_extendedfuncs_t;
|
} ui_extendedfuncs_t;
|
||||||
|
|
||||||
// deprecated export from old engine
|
// deprecated export from old engine
|
||||||
|
2
mainui
2
mainui
@ -1 +1 @@
|
|||||||
Subproject commit 704012ce4e9b31d41cc472e1d117340856301709
|
Subproject commit c3095f477ff4ecfd8bc1f803c6d9e6e63ba32926
|
@ -475,10 +475,10 @@ int EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t *engfuncs,
|
|||||||
void EXPORT GetRefHumanReadableName( char *out, size_t size )
|
void EXPORT GetRefHumanReadableName( char *out, size_t size )
|
||||||
{
|
{
|
||||||
#if defined XASH_NANOGL
|
#if defined XASH_NANOGL
|
||||||
Q_strncpy( out, "OpenGLES 1(NanoGL)", size );
|
Q_strncpy( out, "GLES1(NanoGL)", size );
|
||||||
#elif defined XASH_WES
|
#elif defined XASH_WES
|
||||||
Q_strncpy( out, "OpenGLES 2(gl-wes-v2)", size );
|
Q_strncpy( out, "GLES2(gl-wes-v2)", size );
|
||||||
#else
|
#else
|
||||||
Q_strncpy( out, "OpenGL 1.x", size );
|
Q_strncpy( out, "OpenGL", size );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user