Skip to content

Commit

Permalink
SDL_GL_LoadLibrary() has slightly different behavior between 1.2 and …
Browse files Browse the repository at this point in the history
…2.0.
  • Loading branch information
icculus committed Feb 28, 2019
1 parent 46a2fcb commit aa99b4a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/SDL12_compat.c
Expand Up @@ -3054,6 +3054,36 @@ SDL_FreeYUVOverlay(SDL12_Overlay * overlay)
FIXME("write me");
}

DECLSPEC int SDLCALL
SDL_GL_LoadLibrary(const char *libname)
{
/* SDL 1.2 would unload the previous library if one was loaded. SDL2
reports an error if one is already loaded, and sometimes loads it
internally for some video targets, so unloading it probably isn't safe.
There really isn't a good reason to be using anything other than the
system OpenGL in 2019, so we ignore the error in this case to match 1.2
behavior, even if you were going to load a different library this time.
Oh well. */
const int rc = SDL20_GL_LoadLibrary(libname);
if (rc == -1) {
const char *err = SDL20_GetError();
if (SDL20_strcmp(err, "OpenGL library already loaded") == 0) {
return 0;
}

/* reset the actual error. */
char *dup = SDL_strdup(err);
if (!dup) {
SDL20_SetError("Out of memory");
} else {
SDL20_SetError(dup);
SDL_free(dup);
}
}
return rc;
}


DECLSPEC int SDLCALL
SDL_GL_SetAttribute(SDL12_GLattr attr, int value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SDL20_syms.h
Expand Up @@ -98,7 +98,7 @@ SDL20_SYM(int,GetColorKey,(SDL_Surface *a, Uint32 *b),(a,b),return)
SDL20_SYM(void,FreeSurface,(SDL_Surface *a),(a),)
SDL20_SYM(SDL_Surface*,LoadBMP_RW,(SDL_RWops *a, int b),(a,b),return)
SDL20_SYM(int,SaveBMP_RW,(SDL_Surface *a, SDL_RWops *b, int c),(a,b,c),return)
SDL20_SYM_PASSTHROUGH(int,GL_LoadLibrary,(const char *a),(a),return)
SDL20_SYM(int,GL_LoadLibrary,(const char *a),(a),return)
SDL20_SYM_PASSTHROUGH(void *,GL_GetProcAddress,(const char *a),(a),return)
SDL20_SYM(int,GL_SetAttribute,(SDL_GLattr a, int b),(a,b),return)
SDL20_SYM(int,GL_GetAttribute,(SDL_GLattr a, int *b),(a,b),return)
Expand Down

0 comments on commit aa99b4a

Please sign in to comment.