[SDL] Bug with dynamic GL loading

Anders F Björklund afb at algonet.se
Wed Sep 7 01:07:38 PDT 2005


Was trying the old Mac binaries out, was
wondering why "testgl" just failed to run:

Couldn't set GL mode: Couldn't load GL function: glBegin

First I changed it, to report a more useful
error message than just "it failed, sir":

Couldn't set GL mode: Couldn't load GL function glBegin: No GL driver 
has been loaded

Ah, so that explains it then... No library handle.
Wonder if that's a (Classic) Mac-specific little bug ?

The other drivers seem to be loading GL with the context:

XVisualInfo *X11_GL_GetVisual(_THIS)
	...
	/* load the gl driver from a default path */
	if ( ! this->gl_config.driver_loaded ) {
	        /* no driver has been loaded, use default (ourselves) */
	        if ( X11_GL_LoadLibrary(this, NULL) < 0 ) {
		        return NULL;
		}
	}

int WIN_GL_SetupWindow(_THIS)
	...
	/* load the gl driver from a default path */
	if ( ! this->gl_config.driver_loaded ) {
		/* no driver has been loaded, use default (ourselves) */
		if ( WIN_GL_LoadLibrary(this, NULL) < 0 ) {
			return(-1);
		}
	}

Should I add a similar call to the Macintosh driver ?
(I couldn't see where it unloaded the library, though)

int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags) {
	...
     /* Convince SDL that the GL "driver" is loaded */
     this->gl_config.driver_loaded = 1;

This looks like a hack, should probably use above code.


I just inserted a call to "SDL_GL_LoadLibrary(NULL);"
before the #include "SDL_glfuncs.h", and it worked.

Here's the quick-and-dirty patch:
http://www.algonet.se/~afb/SDL-1.2.9-dyngl.patch

This probably leaks a lib handle, so it should most likely
be handled better. But at least it works properly, with GL ?

The Quartz version seems to be "cheating" here anyway, as it
loads and unloads the CFBundle for every GL_GetProcAddress ?

--anders





More information about the SDL mailing list