comparison src/video/x11/SDL_x11gl.c @ 1689:109bdfe06b31 SDL-1.3

Fixed bug #232 ------- Comment #2 From Matthias Geissert 2006-05-24 07:54 [reply] ------- See http://dri.sourceforge.net/doc/DRIuserguide.html, section 11.5. There is written that you need to use RTLD_GLOBAL, since, otherwise, nested open of dynamic libraries doesn't work. However, This is necassary in this case, since libGL opens the hardware-specific driver/library. I hope this helps you.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 20 Jun 2006 05:23:22 +0000
parents 4da1ee79c9af
children a51dfda0ff33
comparison
equal deleted inserted replaced
1688:c553a990dc32 1689:109bdfe06b31
433 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window); 433 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window);
434 } 434 }
435 435
436 #endif /* SDL_VIDEO_OPENGL_GLX */ 436 #endif /* SDL_VIDEO_OPENGL_GLX */
437 437
438 #define OPENGL_REQUIRS_DLOPEN
439 #if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN)
440 #include <dlfcn.h>
441 #define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL))
442 #define GL_LoadFunction dlsym
443 #define GL_UnloadObject dlclose
444 #else
445 #define GL_LoadObject SDL_LoadObject
446 #define GL_LoadFunction SDL_LoadFunction
447 #define GL_UnloadObject SDL_UnloadObject
448 #endif
449
438 void 450 void
439 X11_GL_UnloadLibrary(_THIS) 451 X11_GL_UnloadLibrary(_THIS)
440 { 452 {
441 #if SDL_VIDEO_OPENGL_GLX 453 #if SDL_VIDEO_OPENGL_GLX
442 if (this->gl_config.driver_loaded) { 454 if (this->gl_config.driver_loaded) {
443 455
444 SDL_UnloadObject(this->gl_config.dll_handle); 456 GL_UnloadObject(this->gl_config.dll_handle);
445 457
446 this->gl_data->glXGetProcAddress = NULL; 458 this->gl_data->glXGetProcAddress = NULL;
447 this->gl_data->glXChooseVisual = NULL; 459 this->gl_data->glXChooseVisual = NULL;
448 this->gl_data->glXCreateContext = NULL; 460 this->gl_data->glXCreateContext = NULL;
449 this->gl_data->glXDestroyContext = NULL; 461 this->gl_data->glXDestroyContext = NULL;
477 if (path == NULL) { 489 if (path == NULL) {
478 path = DEFAULT_OPENGL; 490 path = DEFAULT_OPENGL;
479 } 491 }
480 } 492 }
481 493
482 handle = SDL_LoadObject(path); 494 handle = GL_LoadObject(path);
483 if (handle == NULL) { 495 if (handle == NULL) {
484 /* SDL_LoadObject() will call SDL_SetError() for us. */ 496 /* SDL_LoadObject() will call SDL_SetError() for us. */
485 return -1; 497 return -1;
486 } 498 }
487 499
488 /* Unload the old driver and reset the pointers */ 500 /* Unload the old driver and reset the pointers */
489 X11_GL_UnloadLibrary(this); 501 X11_GL_UnloadLibrary(this);
490 502
491 /* Load new function pointers */ 503 /* Load new function pointers */
492 this->gl_data->glXGetProcAddress = 504 this->gl_data->glXGetProcAddress =
493 (void *(*)(const GLubyte *)) SDL_LoadFunction(handle, 505 (void *(*)(const GLubyte *)) GL_LoadFunction(handle,
494 "glXGetProcAddressARB"); 506 "glXGetProcAddressARB");
495 this->gl_data->glXChooseVisual = 507 this->gl_data->glXChooseVisual =
496 (XVisualInfo * (*)(Display *, int, int *)) SDL_LoadFunction(handle, 508 (XVisualInfo * (*)(Display *, int, int *)) GL_LoadFunction(handle,
497 "glXChooseVisual"); 509 "glXChooseVisual");
498 this->gl_data->glXCreateContext = 510 this->gl_data->glXCreateContext =
499 (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int)) 511 (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int))
500 SDL_LoadFunction(handle, "glXCreateContext"); 512 GL_LoadFunction(handle, "glXCreateContext");
501 this->gl_data->glXDestroyContext = 513 this->gl_data->glXDestroyContext =
502 (void (*)(Display *, GLXContext)) SDL_LoadFunction(handle, 514 (void (*)(Display *, GLXContext)) GL_LoadFunction(handle,
503 "glXDestroyContext"); 515 "glXDestroyContext");
504 this->gl_data->glXMakeCurrent = 516 this->gl_data->glXMakeCurrent =
505 (int (*)(Display *, GLXDrawable, GLXContext)) 517 (int (*)(Display *, GLXDrawable, GLXContext)) GL_LoadFunction(handle,
506 SDL_LoadFunction(handle, "glXMakeCurrent"); 518 "glXMakeCurrent");
507 this->gl_data->glXSwapBuffers = 519 this->gl_data->glXSwapBuffers =
508 (void (*)(Display *, GLXDrawable)) SDL_LoadFunction(handle, 520 (void (*)(Display *, GLXDrawable)) GL_LoadFunction(handle,
509 "glXSwapBuffers"); 521 "glXSwapBuffers");
510 this->gl_data->glXGetConfig = 522 this->gl_data->glXGetConfig =
511 (int (*)(Display *, XVisualInfo *, int, int *)) 523 (int (*)(Display *, XVisualInfo *, int, int *))
512 SDL_LoadFunction(handle, "glXGetConfig"); 524 GL_LoadFunction(handle, "glXGetConfig");
513 this->gl_data->glXQueryExtensionsString = 525 this->gl_data->glXQueryExtensionsString =
514 (const char *(*)(Display *, int)) SDL_LoadFunction(handle, 526 (const char *(*)(Display *, int)) GL_LoadFunction(handle,
515 "glXQueryExtensionsString"); 527 "glXQueryExtensionsString");
516 this->gl_data->glXSwapIntervalSGI = 528 this->gl_data->glXSwapIntervalSGI =
517 (int (*)(int)) SDL_LoadFunction(handle, "glXSwapIntervalSGI"); 529 (int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI");
518 this->gl_data->glXSwapIntervalMESA = 530 this->gl_data->glXSwapIntervalMESA =
519 (GLint(*)(unsigned)) SDL_LoadFunction(handle, "glXSwapIntervalMESA"); 531 (GLint(*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA");
520 this->gl_data->glXGetSwapIntervalMESA = 532 this->gl_data->glXGetSwapIntervalMESA =
521 (GLint(*)(void)) SDL_LoadFunction(handle, "glXGetSwapIntervalMESA"); 533 (GLint(*)(void)) GL_LoadFunction(handle, "glXGetSwapIntervalMESA");
522 534
523 if ((this->gl_data->glXChooseVisual == NULL) || 535 if ((this->gl_data->glXChooseVisual == NULL) ||
524 (this->gl_data->glXCreateContext == NULL) || 536 (this->gl_data->glXCreateContext == NULL) ||
525 (this->gl_data->glXDestroyContext == NULL) || 537 (this->gl_data->glXDestroyContext == NULL) ||
526 (this->gl_data->glXMakeCurrent == NULL) || 538 (this->gl_data->glXMakeCurrent == NULL) ||
549 561
550 handle = this->gl_config.dll_handle; 562 handle = this->gl_config.dll_handle;
551 if (this->gl_data->glXGetProcAddress) { 563 if (this->gl_data->glXGetProcAddress) {
552 return this->gl_data->glXGetProcAddress((const GLubyte *) proc); 564 return this->gl_data->glXGetProcAddress((const GLubyte *) proc);
553 } 565 }
554 return SDL_LoadFunction(handle, proc); 566 return GL_LoadFunction(handle, proc);
555 } 567 }
556 568
557 #endif /* SDL_VIDEO_OPENGL_GLX */ 569 #endif /* SDL_VIDEO_OPENGL_GLX */
558 /* vi: set ts=4 sw=4 expandtab: */