Fixed bug 1006 SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Sun, 18 Jul 2010 11:11:37 -0700
branchSDL-1.2
changeset 45466f0706a60146
parent 4545 134c6707b767
child 4547 963f939494a1
Fixed bug 1006

Get the GLX functions with glXGetProcAddress() when available.
src/video/x11/SDL_x11gl.c
     1.1 --- a/src/video/x11/SDL_x11gl.c	Sun Jul 18 10:51:25 2010 -0700
     1.2 +++ b/src/video/x11/SDL_x11gl.c	Sun Jul 18 11:11:37 2010 -0700
     1.3 @@ -512,27 +512,30 @@
     1.4  	/* Unload the old driver and reset the pointers */
     1.5  	X11_GL_UnloadLibrary(this);
     1.6  
     1.7 +	/* Save the handle for X11_GL_GetProcAddress() */
     1.8 +	this->gl_config.dll_handle = handle;
     1.9 +
    1.10  	/* Load new function pointers */
    1.11  	this->gl_data->glXGetProcAddress =
    1.12  		(void *(*)(const GLubyte *)) GL_LoadFunction(handle, "glXGetProcAddressARB");
    1.13  	this->gl_data->glXChooseVisual =
    1.14 -		(XVisualInfo *(*)(Display *, int, int *)) GL_LoadFunction(handle, "glXChooseVisual");
    1.15 +		(XVisualInfo *(*)(Display *, int, int *)) X11_GL_GetProcAddress(this, "glXChooseVisual");
    1.16  	this->gl_data->glXCreateContext =
    1.17 -		(GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) GL_LoadFunction(handle, "glXCreateContext");
    1.18 +		(GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) X11_GL_GetProcAddress(this, "glXCreateContext");
    1.19  	this->gl_data->glXDestroyContext =
    1.20 -		(void (*)(Display *, GLXContext)) GL_LoadFunction(handle, "glXDestroyContext");
    1.21 +		(void (*)(Display *, GLXContext)) X11_GL_GetProcAddress(this, "glXDestroyContext");
    1.22  	this->gl_data->glXMakeCurrent =
    1.23 -		(int (*)(Display *, GLXDrawable, GLXContext)) GL_LoadFunction(handle, "glXMakeCurrent");
    1.24 +		(int (*)(Display *, GLXDrawable, GLXContext)) X11_GL_GetProcAddress(this, "glXMakeCurrent");
    1.25  	this->gl_data->glXSwapBuffers =
    1.26 -		(void (*)(Display *, GLXDrawable)) GL_LoadFunction(handle, "glXSwapBuffers");
    1.27 +		(void (*)(Display *, GLXDrawable)) X11_GL_GetProcAddress(this, "glXSwapBuffers");
    1.28  	this->gl_data->glXGetConfig =
    1.29 -		(int (*)(Display *, XVisualInfo *, int, int *)) GL_LoadFunction(handle, "glXGetConfig");
    1.30 +		(int (*)(Display *, XVisualInfo *, int, int *)) X11_GL_GetProcAddress(this, "glXGetConfig");
    1.31  	this->gl_data->glXQueryExtensionsString =
    1.32 -		(const char *(*)(Display *, int)) GL_LoadFunction(handle, "glXQueryExtensionsString");
    1.33 +		(const char *(*)(Display *, int)) X11_GL_GetProcAddress(this, "glXQueryExtensionsString");
    1.34  	this->gl_data->glXSwapIntervalSGI =
    1.35 -		(int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI");
    1.36 +		(int (*)(int)) X11_GL_GetProcAddress(this, "glXSwapIntervalSGI");
    1.37  	this->gl_data->glXSwapIntervalMESA =
    1.38 -		(GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA");
    1.39 +		(GLint (*)(unsigned)) X11_GL_GetProcAddress(this, "glXSwapIntervalMESA");
    1.40  
    1.41  	if ( (this->gl_data->glXChooseVisual == NULL) || 
    1.42  	     (this->gl_data->glXCreateContext == NULL) ||
    1.43 @@ -541,11 +544,12 @@
    1.44  	     (this->gl_data->glXSwapBuffers == NULL) ||
    1.45  	     (this->gl_data->glXGetConfig == NULL) ||
    1.46  	     (this->gl_data->glXQueryExtensionsString == NULL)) {
    1.47 +		GL_UnloadObject(this->gl_config.dll_handle);
    1.48 +		this->gl_config.dll_handle = NULL;
    1.49  		SDL_SetError("Could not retrieve OpenGL functions");
    1.50  		return -1;
    1.51  	}
    1.52  
    1.53 -	this->gl_config.dll_handle = handle;
    1.54  	this->gl_config.driver_loaded = 1;
    1.55  	if ( path ) {
    1.56  		SDL_strlcpy(this->gl_config.driver_path, path,
    1.57 @@ -558,13 +562,10 @@
    1.58  
    1.59  void *X11_GL_GetProcAddress(_THIS, const char* proc)
    1.60  {
    1.61 -	void* handle;
    1.62 -	
    1.63 -	handle = this->gl_config.dll_handle;
    1.64  	if ( this->gl_data->glXGetProcAddress ) {
    1.65  		return this->gl_data->glXGetProcAddress((const GLubyte *)proc);
    1.66  	}
    1.67 -	return GL_LoadFunction(handle, proc);
    1.68 +	return GL_LoadFunction(this->gl_config.dll_handle, proc);
    1.69  }
    1.70  
    1.71  #endif /* SDL_VIDEO_OPENGL_GLX */