From c1d1aa6787aa57d915b733b39fceb6484f2c917b Mon Sep 17 00:00:00 2001 From: mittorn Date: Sat, 21 Oct 2023 20:11:58 +0300 Subject: [PATCH] ref_gl: rewrite ARB workaround to check EXT/OES names, notify user that function found with different name --- ref/gl/gl_opengl.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/ref/gl/gl_opengl.c b/ref/gl/gl_opengl.c index d973e631..efa8d3db 100644 --- a/ref/gl/gl_opengl.c +++ b/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 if((*func->func = (void *)gEngfuncs.GL_GetProcAddress( func->name )) == NULL ) { + + string name; + // HACK: fix ARB names - char *str = Q_strstr( func->name, "ARB" ); - if(str) - { - string name; + const char *str = Q_strstr( func->name, "ARB" ); + Q_strncpy( name, func->name, MAX_STRING ); - 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'; + } + + // try glFuncEXT + if( !*func->func ) + { + Q_strncat( name, "EXT", MAX_STRING ); *func->func = gEngfuncs.GL_GetProcAddress( name ); + } - if( !*func->func ) - GL_SetExtension( r_ext, false ); +#ifdef XASH_GLES + // 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 - // one or more functions are invalid, extension will be disabled +#endif + if( !*func->func ) 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