Browse Source

ref_gl: rewrite ARB workaround to check EXT/OES names, notify user that function found with different name

pull/2/head
mittorn 9 months ago committed by Alibek Omarov
parent
commit
c1d1aa6787
  1. 42
      ref/gl/gl_opengl.c

42
ref/gl/gl_opengl.c

@ -551,22 +551,46 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
// 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;
// HACK: fix ARB names // HACK: fix ARB names
char *str = Q_strstr( func->name, "ARB" ); const char *str = Q_strstr( func->name, "ARB" );
if(str) Q_strncpy( name, func->name, MAX_STRING );
{
string name;
Q_strncpy( name, func->name, MAX_STRING ); if( str )
{
name[str - func->name] = '\0'; // cut func suffix
// if this was glFuncARB, try glFunc
*func->func = gEngfuncs.GL_GetProcAddress( name );
}
else
{
// set pointer to func name end to cut it correctly
str = func->name + Q_strlen( func->name );
name[str - func->name] = '\0'; name[str - func->name] = '\0';
}
// try glFuncEXT
if( !*func->func )
{
Q_strncat( name, "EXT", MAX_STRING );
*func->func = gEngfuncs.GL_GetProcAddress( name ); *func->func = gEngfuncs.GL_GetProcAddress( name );
}
if( !*func->func ) #ifdef XASH_GLES
GL_SetExtension( r_ext, false ); // try glFuncOES
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 );
} }
else #endif
// one or more functions are invalid, extension will be disabled 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…
Cancel
Save