mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-25 22:34:24 +00:00
ref: gl: more simple search of GL func with alternative name (EXT, OES suffixes or no suffix)
This commit is contained in:
parent
3ac8ad9484
commit
3251b68df5
@ -549,48 +549,54 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
|
|||||||
for( func = funcs; func && func->name; func++ )
|
for( func = funcs; func && func->name; func++ )
|
||||||
{
|
{
|
||||||
// functions are cleared before all the extensions are evaluated
|
// functions are cleared before all the extensions are evaluated
|
||||||
if((*func->func = (void *)gEngfuncs.GL_GetProcAddress( func->name )) == NULL )
|
if(( *func->func = (void *)gEngfuncs.GL_GetProcAddress( func->name )) == NULL )
|
||||||
{
|
{
|
||||||
|
|
||||||
string name;
|
string name;
|
||||||
|
char *end;
|
||||||
|
size_t i = 0;
|
||||||
|
#ifdef XASH_GLES
|
||||||
|
const char *suffixes[] = { "", "EXT", "OES" };
|
||||||
|
#else
|
||||||
|
const char *suffixes[] = { "", "EXT" };
|
||||||
|
#endif
|
||||||
|
|
||||||
// HACK: fix ARB names
|
// HACK: fix ARB names
|
||||||
const char *str = Q_strstr( func->name, "ARB" );
|
Q_strncpy( name, func->name, sizeof( name ));
|
||||||
Q_strncpy( name, func->name, MAX_STRING );
|
if(( end = Q_strstr( name, "ARB" )))
|
||||||
|
|
||||||
if( str )
|
|
||||||
{
|
{
|
||||||
name[str - func->name] = '\0'; // cut func suffix
|
*end = '\0';
|
||||||
// if this was glFuncARB, try glFunc
|
|
||||||
*func->func = gEngfuncs.GL_GetProcAddress( name );
|
|
||||||
}
|
}
|
||||||
else
|
else // I need Q_strstrnul
|
||||||
{
|
{
|
||||||
// set pointer to func name end to cut it correctly
|
end = name + Q_strlen( name );
|
||||||
str = func->name + Q_strlen( func->name );
|
i++; // skip empty suffix
|
||||||
name[str - func->name] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// try glFuncEXT
|
for( ; i < sizeof( suffixes ) / sizeof( suffixes[0] ); i++ )
|
||||||
if( !*func->func )
|
|
||||||
{
|
{
|
||||||
Q_strncat( name, "EXT", MAX_STRING );
|
void *f;
|
||||||
*func->func = gEngfuncs.GL_GetProcAddress( name );
|
|
||||||
|
Q_strncat( name, suffixes[i], sizeof( name ));
|
||||||
|
|
||||||
|
if(( f = gEngfuncs.GL_GetProcAddress( name )))
|
||||||
|
{
|
||||||
|
// GL_GetProcAddress prints errors about missing functions, so tell user that we found it with different name
|
||||||
|
gEngfuncs.Con_Printf( S_NOTE "found %s\n", name );
|
||||||
|
|
||||||
|
*func->func = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*end = '\0'; // cut suffix, try next
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XASH_GLES
|
// not found...
|
||||||
// try glFuncOES
|
if( i == sizeof( suffixes ) / sizeof( suffixes[0] ))
|
||||||
if( !*func->func )
|
|
||||||
{
|
{
|
||||||
name[str - func->name] = '\0'; // cut EXT from previous try
|
|
||||||
Q_strncat( name, "OES", MAX_STRING );
|
|
||||||
*func->func = gEngfuncs.GL_GetProcAddress( name );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if( !*func->func )
|
|
||||||
GL_SetExtension( r_ext, false );
|
GL_SetExtension( r_ext, false );
|
||||||
else // GL_GetProcAddress prints errors about missing functions, so tell user that we found it with different name
|
}
|
||||||
gEngfuncs.Con_Printf( S_NOTE "found %s\n", name );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user