Browse Source

engine: implement menu extensions to allow choosing renderers from GUI

pull/2/head
Alibek Omarov 5 years ago
parent
commit
8323df240b
  1. 17
      engine/client/cl_gameui.c
  2. 11
      engine/client/ref_common.c
  3. 9
      engine/client/ref_common.h
  4. 2
      engine/menu_int.h
  5. 2
      mainui
  6. 6
      ref_gl/gl_context.c

17
engine/client/cl_gameui.c

@ -1185,12 +1185,27 @@ static void pfnEnableTextInput( int enable ) @@ -1185,12 +1185,27 @@ static void pfnEnableTextInput( int enable )
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 =
{
pfnEnableTextInput,
Con_UtfProcessChar,
Con_UtfMoveLeft,
Con_UtfMoveRight
Con_UtfMoveRight,
pfnGetRenderers
};
void UI_UnloadProgs( void )

11
engine/client/ref_common.c

@ -573,9 +573,8 @@ void R_CollectRendererNames( void ) @@ -573,9 +573,8 @@ void R_CollectRendererNames( void )
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;
void *dll, *pfn;
@ -592,21 +591,21 @@ void R_CollectRendererNames( void ) @@ -592,21 +591,21 @@ void R_CollectRendererNames( void )
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 );
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
{
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++;
COM_FreeLibrary( dll );

9
engine/client/ref_common.h

@ -20,12 +20,6 @@ GNU General Public License for more details. @@ -20,12 +20,6 @@ GNU General Public License for more details.
#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
{
qboolean initialized;
@ -34,7 +28,8 @@ struct ref_state_s @@ -34,7 +28,8 @@ struct ref_state_s
ref_interface_t dllFuncs;
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;

2
engine/menu_int.h

@ -202,6 +202,8 @@ typedef struct ui_extendedfuncs_s { @@ -202,6 +202,8 @@ typedef struct ui_extendedfuncs_s {
int (*pfnUtfMoveRight) ( char *str, int pos, int length );
// 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;
// deprecated export from old engine

2
mainui

@ -1 +1 @@ @@ -1 +1 @@
Subproject commit 704012ce4e9b31d41cc472e1d117340856301709
Subproject commit c3095f477ff4ecfd8bc1f803c6d9e6e63ba32926

6
ref_gl/gl_context.c

@ -475,10 +475,10 @@ int EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t *engfuncs, @@ -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 )
{
#if defined XASH_NANOGL
Q_strncpy( out, "OpenGLES 1(NanoGL)", size );
Q_strncpy( out, "GLES1(NanoGL)", size );
#elif defined XASH_WES
Q_strncpy( out, "OpenGLES 2(gl-wes-v2)", size );
Q_strncpy( out, "GLES2(gl-wes-v2)", size );
#else
Q_strncpy( out, "OpenGL 1.x", size );
Q_strncpy( out, "OpenGL", size );
#endif
}

Loading…
Cancel
Save