diff --git a/src/SDL_loadso.c b/src/SDL_loadso.c index ad4aaf287..8996bfe4c 100644 --- a/src/SDL_loadso.c +++ b/src/SDL_loadso.c @@ -98,6 +98,7 @@ void *SDL_LoadObject(const char *sofile) kLoadCFrag, &library_id, &mainAddr, errName); switch (error) { case noErr: + loaderror = NULL; break; case cfragNoLibraryErr: loaderror = "Library not found"; diff --git a/src/video/maccommon/SDL_lowvideo.h b/src/video/maccommon/SDL_lowvideo.h index bcae24306..26a69338f 100644 --- a/src/video/maccommon/SDL_lowvideo.h +++ b/src/video/maccommon/SDL_lowvideo.h @@ -89,6 +89,8 @@ struct SDL_PrivateVideoData { #ifdef HAVE_OPENGL AGLContext appleGLContext; + + void *libraryHandle; #endif }; /* Old variable names */ diff --git a/src/video/maccommon/SDL_macevents.c b/src/video/maccommon/SDL_macevents.c index 5cb71fec5..3c9e833f7 100644 --- a/src/video/maccommon/SDL_macevents.c +++ b/src/video/maccommon/SDL_macevents.c @@ -384,6 +384,11 @@ static int Mac_HandleEvents(_THIS, int wait4it) #endif case updateEvt: { BeginUpdate(SDL_Window); + #ifdef HAVE_OPENGL + if (SDL_VideoSurface->flags & SDL_OPENGL) + SDL_GL_SwapBuffers(); + else + #endif if ( (SDL_VideoSurface->flags & SDL_HWSURFACE) == SDL_SWSURFACE ) { SDL_UpdateRect(SDL_VideoSurface, 0, 0, 0, 0); diff --git a/src/video/maccommon/SDL_macgl.c b/src/video/maccommon/SDL_macgl.c index 2996661e5..13cb73f04 100644 --- a/src/video/maccommon/SDL_macgl.c +++ b/src/video/maccommon/SDL_macgl.c @@ -30,6 +30,7 @@ static char rcsid = #include "SDL_error.h" #include "SDL_lowvideo.h" #include "SDL_macgl_c.h" +#include "SDL_loadso.h" /* krat: adding OpenGL support */ @@ -156,5 +157,29 @@ void Mac_GL_SwapBuffers(_THIS) aglSwapBuffers(glContext); } +int Mac_GL_LoadLibrary(_THIS, const char *location) +{ + if (location == NULL) + location = "OpenGLLibrary"; + + this->hidden->libraryHandle = SDL_LoadObject(location); + + this->gl_config.driver_loaded = 1; + return (this->hidden->libraryHandle != NULL) ? 0 : -1; +} + +void Mac_GL_UnloadLibrary(_THIS) +{ + SDL_UnloadObject(this->hidden->libraryHandle); + + this->hidden->libraryHandle = NULL; + this->gl_config.driver_loaded = 0; +} + +void* Mac_GL_GetProcAddress(_THIS, const char *proc) +{ + return SDL_LoadFunction( this->hidden->libraryHandle, proc ); +} + #endif /* HAVE_OPENGL */ diff --git a/src/video/maccommon/SDL_macgl_c.h b/src/video/maccommon/SDL_macgl_c.h index 918be8a6a..eab5c2e6e 100644 --- a/src/video/maccommon/SDL_macgl_c.h +++ b/src/video/maccommon/SDL_macgl_c.h @@ -44,5 +44,8 @@ extern void Mac_GL_Quit(_THIS); extern int Mac_GL_MakeCurrent(_THIS); extern int Mac_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); extern void Mac_GL_SwapBuffers(_THIS); +extern int Mac_GL_LoadLibrary(_THIS, const char *location); +extern void Mac_GL_UnloadLibrary(_THIS); +extern void* Mac_GL_GetProcAddress(_THIS, const char *proc); #endif diff --git a/src/video/macrom/SDL_romvideo.c b/src/video/macrom/SDL_romvideo.c index 79831f5d6..a82b968ae 100644 --- a/src/video/macrom/SDL_romvideo.c +++ b/src/video/macrom/SDL_romvideo.c @@ -163,6 +163,8 @@ static SDL_VideoDevice *ROM_CreateDevice(int devindex) #ifdef HAVE_OPENGL device->GL_MakeCurrent = Mac_GL_MakeCurrent; device->GL_SwapBuffers = Mac_GL_SwapBuffers; + device->GL_LoadLibrary = Mac_GL_LoadLibrary; + device->GL_GetProcAddress = Mac_GL_GetProcAddress; #endif device->SetCaption = Mac_SetCaption; device->SetIcon = NULL;