src/SDL12_compat.c
changeset 87 9dc1cdfa0fa9
parent 86 4b12bf655509
child 88 60cb434b52b8
     1.1 --- a/src/SDL12_compat.c	Thu Feb 28 09:42:52 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Thu Feb 28 09:43:17 2019 -0500
     1.3 @@ -3055,6 +3055,36 @@
     1.4  }
     1.5  
     1.6  DECLSPEC int SDLCALL
     1.7 +SDL_GL_LoadLibrary(const char *libname)
     1.8 +{
     1.9 +    /* SDL 1.2 would unload the previous library if one was loaded. SDL2
    1.10 +       reports an error if one is already loaded, and sometimes loads it
    1.11 +       internally for some video targets, so unloading it probably isn't safe.
    1.12 +       There really isn't a good reason to be using anything other than the
    1.13 +       system OpenGL in 2019, so we ignore the error in this case to match 1.2
    1.14 +       behavior, even if you were going to load a different library this time.
    1.15 +       Oh well. */
    1.16 +    const int rc = SDL20_GL_LoadLibrary(libname);
    1.17 +    if (rc == -1) {
    1.18 +        const char *err = SDL20_GetError();
    1.19 +        if (SDL20_strcmp(err, "OpenGL library already loaded") == 0) {
    1.20 +            return 0;
    1.21 +        }
    1.22 +
    1.23 +        /* reset the actual error. */
    1.24 +        char *dup = SDL_strdup(err);
    1.25 +        if (!dup) {
    1.26 +            SDL20_SetError("Out of memory");
    1.27 +        } else {
    1.28 +            SDL20_SetError(dup);
    1.29 +            SDL_free(dup);
    1.30 +        }
    1.31 +    }
    1.32 +    return rc;
    1.33 +}
    1.34 +
    1.35 +
    1.36 +DECLSPEC int SDLCALL
    1.37  SDL_GL_SetAttribute(SDL12_GLattr attr, int value)
    1.38  {
    1.39      if (attr >= SDL12_GL_MAX_ATTRIBUTE)