Skip to content

Commit

Permalink
ref_gl: add workarounds for detecting extensions correctly on gles1/g…
Browse files Browse the repository at this point in the history
…les2 without wrapper (swiftshader works now)
  • Loading branch information
mittorn committed Oct 13, 2023
1 parent 44243e2 commit e6b4274
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions ref/gl/gl_opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ static dllfunc_t vbofuncs[] =
{ GL_CALL( glDeleteBuffersARB ) },
{ GL_CALL( glGenBuffersARB ) },
{ GL_CALL( glIsBufferARB ) },
#ifndef XASH_GLES
{ GL_CALL( glMapBufferARB ) },
{ GL_CALL( glUnmapBufferARB ) }, // ,
{ GL_CALL( glUnmapBufferARB ) },
#endif
{ GL_CALL( glBufferDataARB ) },
{ GL_CALL( glBufferSubDataARB ) },
{ NULL, NULL }
Expand Down Expand Up @@ -259,6 +261,9 @@ static dllfunc_t mapbufferrangefuncs[] =
{
{ GL_CALL( glMapBufferRange ) },
{ GL_CALL( glFlushMappedBufferRange ) },
#ifdef XASH_GLES
{ GL_CALL( glUnmapBufferARB ) },
#endif
{ NULL, NULL }
};

Expand Down Expand Up @@ -363,10 +368,10 @@ static dllfunc_t shaderobjectsfuncs_gles[] =
{ "glUniformMatrix2fv" , (void **)&pglUniformMatrix2fvARB },
{ "glUniformMatrix3fv" , (void **)&pglUniformMatrix3fvARB },
{ "glUniformMatrix4fv" , (void **)&pglUniformMatrix4fvARB },
{ "glGetShaderfv" , (void **)&pglGetObjectParameterfvARB },
// { "glGetShaderfv" , (void **)&pglGetObjectParameterfvARB }, // missing in ES2?
{ "glGetShaderiv" , (void **)&pglGetObjectParameterivARB },
{ "glGetShaderInfoLog" , (void **)&pglGetInfoLogARB },
{ "glGetAttachedObjects" , (void **)&pglGetAttachedObjectsARB },
// { "glGetAttachedObjects" , (void **)&pglGetAttachedObjectsARB }, // missing in ES2?
{ "glGetUniformLocation" , (void **)&pglGetUniformLocationARB },
{ "glGetActiveUniform" , (void **)&pglGetActiveUniformARB },
{ "glGetUniformfv" , (void **)&pglGetUniformfvARB },
Expand Down Expand Up @@ -398,6 +403,23 @@ static dllfunc_t vaofuncs[] =
{ "glIsVertexArray" , (void **)&pglIsVertexArray },
{ NULL, NULL }
};

static dllfunc_t multitexturefuncs_es[] =
{
{ GL_CALL( glActiveTexture ) },
{ GL_CALL( glActiveTextureARB ) },
{ GL_CALL( glClientActiveTexture ) },
{ GL_CALL( glClientActiveTextureARB ) },
{ NULL , NULL }
};

static dllfunc_t multitexturefuncs_es2[] =
{
{ GL_CALL( glActiveTexture ) },
{ GL_CALL( glActiveTextureARB ) },
{ NULL , NULL }
};

#endif

/*
Expand Down Expand Up @@ -516,8 +538,20 @@ 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 )
{
// one or more functions are invalid, extension will be disabled
GL_SetExtension( r_ext, false );
// HACK: fix ARB names
char *str = Q_strstr(func->name, "ARB");
if(str)
{
string name;
Q_strncpy( name, func->name, MAX_STRING );
name[str - func->name] = '\0';
*func->func = gEngfuncs.GL_GetProcAddress( name );
if(!*func->func)
GL_SetExtension( r_ext, false );
}
else
// one or more functions are invalid, extension will be disabled
GL_SetExtension( r_ext, false );
}
}
#endif
Expand Down Expand Up @@ -717,7 +751,9 @@ void GL_InitExtensionsGLES( void )
GL_CheckExtension( "vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", extid, 1.0 );
break;
case GL_ARB_MULTITEXTURE:
GL_CheckExtension( "multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 );
if(!GL_CheckExtension( "multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0) && glConfig.wrapper == GLES_WRAPPER_NONE )
if( !GL_CheckExtension( "multitexture_es1", multitexturefuncs_es, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 ) )
if( !GL_CheckExtension( "multitexture_es2", multitexturefuncs_es2, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 2.0 ) )
//GL_SetExtension( extid, true ); // required to be supported by wrapper

pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units );
Expand Down

0 comments on commit e6b4274

Please sign in to comment.