diff src/video/cocoa/SDL_cocoaopengl.m @ 3057:089a77aebb7d

Added test program for SDL_CreateWindowFrom() Make sure OpenGL library is loaded before working with OpenGL windows, even those created with SDL_CreateWindowFrom()
author Sam Lantinga <slouken@libsdl.org>
date Mon, 09 Feb 2009 05:32:12 +0000
parents 99210400e8b9
children 7812d3e9564e
line wrap: on
line diff
--- a/src/video/cocoa/SDL_cocoaopengl.m	Sun Feb 08 15:35:06 2009 +0000
+++ b/src/video/cocoa/SDL_cocoaopengl.m	Mon Feb 09 05:32:12 2009 +0000
@@ -48,15 +48,7 @@
 int
 Cocoa_GL_LoadLibrary(_THIS, const char *path)
 {
-    if (_this->gl_config.driver_loaded) {
-        if (path) {
-            SDL_SetError("OpenGL library already loaded");
-            return -1;
-        } else {
-            ++_this->gl_config.driver_loaded;
-            return 0;
-        }
-    }
+    /* Load the OpenGL library */
     if (path == NULL) {
         path = SDL_getenv("SDL_OPENGL_LIBRARY");
     }
@@ -69,7 +61,6 @@
     }
     SDL_strlcpy(_this->gl_config.driver_path, path,
                 SDL_arraysize(_this->gl_config.driver_path));
-    _this->gl_config.driver_loaded = 1;
     return 0;
 }
 
@@ -79,68 +70,11 @@
     return SDL_LoadFunction(_this->gl_config.dll_handle, proc);
 }
 
-static void
+void
 Cocoa_GL_UnloadLibrary(_THIS)
 {
-    if (_this->gl_config.driver_loaded > 0) {
-        if (--_this->gl_config.driver_loaded > 0) {
-            return;
-        }
-        SDL_UnloadObject(_this->gl_config.dll_handle);
-        _this->gl_config.dll_handle = NULL;
-    }
-}
-
-static int
-Cocoa_GL_Initialize(_THIS)
-{
-    if (_this->gl_data) {
-        ++_this->gl_data->initialized;
-        return 0;
-    }
-
-    _this->gl_data =
-        (struct SDL_GLDriverData *) SDL_calloc(1,
-                                               sizeof(struct
-                                                      SDL_GLDriverData));
-    if (!_this->gl_data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-    _this->gl_data->initialized = 1;
-
-    if (Cocoa_GL_LoadLibrary(_this, NULL) < 0) {
-        return -1;
-    }
-    return 0;
-}
-
-static void
-Cocoa_GL_Shutdown(_THIS)
-{
-    if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
-        return;
-    }
-
-    Cocoa_GL_UnloadLibrary(_this);
-
-    SDL_free(_this->gl_data);
-    _this->gl_data = NULL;
-}
-
-int
-Cocoa_GL_SetupWindow(_THIS, SDL_Window * window)
-{
-    if (Cocoa_GL_Initialize(_this) < 0) {
-        return -1;
-    }
-    return 0;
-}
-
-void
-Cocoa_GL_CleanupWindow(_THIS, SDL_Window * window)
-{
-    Cocoa_GL_Shutdown(_this);
+    SDL_UnloadObject(_this->gl_config.dll_handle);
+    _this->gl_config.dll_handle = NULL;
 }
 
 SDL_GLContext