src/video/windows/SDL_windowsopengl.c
changeset 7865 f2a42ca4ddf0
parent 7853 4861edda71d1
child 8021 f96e12e0ade9
     1.1 --- a/src/video/windows/SDL_windowsopengl.c	Sun Oct 20 23:52:02 2013 -0700
     1.2 +++ b/src/video/windows/SDL_windowsopengl.c	Mon Oct 21 00:15:24 2013 -0700
     1.3 @@ -23,6 +23,7 @@
     1.4  #if SDL_VIDEO_DRIVER_WINDOWS
     1.5  
     1.6  #include "SDL_assert.h"
     1.7 +#include "SDL_loadso.h"
     1.8  #include "SDL_windowsvideo.h"
     1.9  
    1.10  /* WGL implementation of SDL OpenGL support */
    1.11 @@ -81,8 +82,7 @@
    1.12  int
    1.13  WIN_GL_LoadLibrary(_THIS, const char *path)
    1.14  {
    1.15 -    LPTSTR wpath;
    1.16 -    HANDLE handle;
    1.17 +    void *handle;
    1.18  
    1.19      if (path == NULL) {
    1.20          path = SDL_getenv("SDL_OPENGL_LIBRARY");
    1.21 @@ -90,23 +90,15 @@
    1.22      if (path == NULL) {
    1.23          path = DEFAULT_OPENGL;
    1.24      }
    1.25 -    wpath = WIN_UTF8ToString(path);
    1.26 -    _this->gl_config.dll_handle = LoadLibrary(wpath);
    1.27 -    SDL_free(wpath);
    1.28 +    _this->gl_config.dll_handle = SDL_LoadObject(path);
    1.29      if (!_this->gl_config.dll_handle) {
    1.30 -        char message[1024];
    1.31 -        SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")",
    1.32 -                     path);
    1.33 -        return WIN_SetError(message);
    1.34 +        return -1;
    1.35      }
    1.36      SDL_strlcpy(_this->gl_config.driver_path, path,
    1.37                  SDL_arraysize(_this->gl_config.driver_path));
    1.38  
    1.39      /* Allocate OpenGL memory */
    1.40 -    _this->gl_data =
    1.41 -        (struct SDL_GLDriverData *) SDL_calloc(1,
    1.42 -                                               sizeof(struct
    1.43 -                                                      SDL_GLDriverData));
    1.44 +    _this->gl_data = (struct SDL_GLDriverData *) SDL_calloc(1, sizeof(struct SDL_GLDriverData));
    1.45      if (!_this->gl_data) {
    1.46          return SDL_OutOfMemory();
    1.47      }
    1.48 @@ -114,21 +106,20 @@
    1.49      /* Load function pointers */
    1.50      handle = _this->gl_config.dll_handle;
    1.51      _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
    1.52 -        GetProcAddress(handle, "wglGetProcAddress");
    1.53 +        SDL_LoadFunction(handle, "wglGetProcAddress");
    1.54      _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
    1.55 -        GetProcAddress(handle, "wglCreateContext");
    1.56 +        SDL_LoadFunction(handle, "wglCreateContext");
    1.57      _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
    1.58 -        GetProcAddress(handle, "wglDeleteContext");
    1.59 +        SDL_LoadFunction(handle, "wglDeleteContext");
    1.60      _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
    1.61 -        GetProcAddress(handle, "wglMakeCurrent");
    1.62 +        SDL_LoadFunction(handle, "wglMakeCurrent");
    1.63      _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
    1.64 -        GetProcAddress(handle, "wglShareLists");
    1.65 +        SDL_LoadFunction(handle, "wglShareLists");
    1.66  
    1.67      if (!_this->gl_data->wglGetProcAddress ||
    1.68          !_this->gl_data->wglCreateContext ||
    1.69          !_this->gl_data->wglDeleteContext ||
    1.70          !_this->gl_data->wglMakeCurrent) {
    1.71 -        SDL_UnloadObject(handle);
    1.72          return SDL_SetError("Could not retrieve OpenGL functions");
    1.73      }
    1.74  
    1.75 @@ -152,7 +143,7 @@
    1.76  void
    1.77  WIN_GL_UnloadLibrary(_THIS)
    1.78  {
    1.79 -    FreeLibrary((HMODULE) _this->gl_config.dll_handle);
    1.80 +    SDL_UnloadObject(_this->gl_config.dll_handle);
    1.81      _this->gl_config.dll_handle = NULL;
    1.82  
    1.83      /* Free OpenGL memory */