Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11gl.c @ 1861:b42823412c3b
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 03:52:41 +0000 |
parents | 0495a8e98595 |
children | 9d940db55a91 |
comparison
equal
deleted
inserted
replaced
1860:3cde094c580d | 1861:b42823412c3b |
---|---|
420 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window); | 420 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window); |
421 } | 421 } |
422 | 422 |
423 #endif /* SDL_VIDEO_OPENGL_GLX */ | 423 #endif /* SDL_VIDEO_OPENGL_GLX */ |
424 | 424 |
425 #define OPENGL_REQUIRS_DLOPEN | |
426 #if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN) | |
427 #include <dlfcn.h> | |
428 #define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) | |
429 #define GL_LoadFunction dlsym | |
430 #define GL_UnloadObject dlclose | |
431 #else | |
432 #define GL_LoadObject SDL_LoadObject | |
433 #define GL_LoadFunction SDL_LoadFunction | |
434 #define GL_UnloadObject SDL_UnloadObject | |
435 #endif | |
436 | |
425 void X11_GL_UnloadLibrary(_THIS) | 437 void X11_GL_UnloadLibrary(_THIS) |
426 { | 438 { |
427 #if SDL_VIDEO_OPENGL_GLX | 439 #if SDL_VIDEO_OPENGL_GLX |
428 if ( this->gl_config.driver_loaded ) { | 440 if ( this->gl_config.driver_loaded ) { |
429 | 441 |
430 SDL_UnloadObject(this->gl_config.dll_handle); | 442 GL_UnloadObject(this->gl_config.dll_handle); |
431 | 443 |
432 this->gl_data->glXGetProcAddress = NULL; | 444 this->gl_data->glXGetProcAddress = NULL; |
433 this->gl_data->glXChooseVisual = NULL; | 445 this->gl_data->glXChooseVisual = NULL; |
434 this->gl_data->glXCreateContext = NULL; | 446 this->gl_data->glXCreateContext = NULL; |
435 this->gl_data->glXDestroyContext = NULL; | 447 this->gl_data->glXDestroyContext = NULL; |
462 if ( path == NULL ) { | 474 if ( path == NULL ) { |
463 path = DEFAULT_OPENGL; | 475 path = DEFAULT_OPENGL; |
464 } | 476 } |
465 } | 477 } |
466 | 478 |
467 handle = SDL_LoadObject(path); | 479 handle = GL_LoadObject(path); |
468 if ( handle == NULL ) { | 480 if ( handle == NULL ) { |
469 /* SDL_LoadObject() will call SDL_SetError() for us. */ | 481 /* SDL_LoadObject() will call SDL_SetError() for us. */ |
470 return -1; | 482 return -1; |
471 } | 483 } |
472 | 484 |
473 /* Unload the old driver and reset the pointers */ | 485 /* Unload the old driver and reset the pointers */ |
474 X11_GL_UnloadLibrary(this); | 486 X11_GL_UnloadLibrary(this); |
475 | 487 |
476 /* Load new function pointers */ | 488 /* Load new function pointers */ |
477 this->gl_data->glXGetProcAddress = | 489 this->gl_data->glXGetProcAddress = |
478 (void *(*)(const GLubyte *)) SDL_LoadFunction(handle, "glXGetProcAddressARB"); | 490 (void *(*)(const GLubyte *)) GL_LoadFunction(handle, "glXGetProcAddressARB"); |
479 this->gl_data->glXChooseVisual = | 491 this->gl_data->glXChooseVisual = |
480 (XVisualInfo *(*)(Display *, int, int *)) SDL_LoadFunction(handle, "glXChooseVisual"); | 492 (XVisualInfo *(*)(Display *, int, int *)) GL_LoadFunction(handle, "glXChooseVisual"); |
481 this->gl_data->glXCreateContext = | 493 this->gl_data->glXCreateContext = |
482 (GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) SDL_LoadFunction(handle, "glXCreateContext"); | 494 (GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) GL_LoadFunction(handle, "glXCreateContext"); |
483 this->gl_data->glXDestroyContext = | 495 this->gl_data->glXDestroyContext = |
484 (void (*)(Display *, GLXContext)) SDL_LoadFunction(handle, "glXDestroyContext"); | 496 (void (*)(Display *, GLXContext)) GL_LoadFunction(handle, "glXDestroyContext"); |
485 this->gl_data->glXMakeCurrent = | 497 this->gl_data->glXMakeCurrent = |
486 (int (*)(Display *, GLXDrawable, GLXContext)) SDL_LoadFunction(handle, "glXMakeCurrent"); | 498 (int (*)(Display *, GLXDrawable, GLXContext)) GL_LoadFunction(handle, "glXMakeCurrent"); |
487 this->gl_data->glXSwapBuffers = | 499 this->gl_data->glXSwapBuffers = |
488 (void (*)(Display *, GLXDrawable)) SDL_LoadFunction(handle, "glXSwapBuffers"); | 500 (void (*)(Display *, GLXDrawable)) GL_LoadFunction(handle, "glXSwapBuffers"); |
489 this->gl_data->glXGetConfig = | 501 this->gl_data->glXGetConfig = |
490 (int (*)(Display *, XVisualInfo *, int, int *)) SDL_LoadFunction(handle, "glXGetConfig"); | 502 (int (*)(Display *, XVisualInfo *, int, int *)) GL_LoadFunction(handle, "glXGetConfig"); |
491 this->gl_data->glXQueryExtensionsString = | 503 this->gl_data->glXQueryExtensionsString = |
492 (const char *(*)(Display *, int)) SDL_LoadFunction(handle, "glXQueryExtensionsString"); | 504 (const char *(*)(Display *, int)) GL_LoadFunction(handle, "glXQueryExtensionsString"); |
493 this->gl_data->glXSwapIntervalSGI = | 505 this->gl_data->glXSwapIntervalSGI = |
494 (int (*)(int)) SDL_LoadFunction(handle, "glXSwapIntervalSGI"); | 506 (int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI"); |
495 this->gl_data->glXSwapIntervalMESA = | 507 this->gl_data->glXSwapIntervalMESA = |
496 (GLint (*)(unsigned)) SDL_LoadFunction(handle, "glXSwapIntervalMESA"); | 508 (GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA"); |
497 this->gl_data->glXGetSwapIntervalMESA = | 509 this->gl_data->glXGetSwapIntervalMESA = |
498 (GLint (*)(void)) SDL_LoadFunction(handle, "glXGetSwapIntervalMESA"); | 510 (GLint (*)(void)) GL_LoadFunction(handle, "glXGetSwapIntervalMESA"); |
499 | 511 |
500 if ( (this->gl_data->glXChooseVisual == NULL) || | 512 if ( (this->gl_data->glXChooseVisual == NULL) || |
501 (this->gl_data->glXCreateContext == NULL) || | 513 (this->gl_data->glXCreateContext == NULL) || |
502 (this->gl_data->glXDestroyContext == NULL) || | 514 (this->gl_data->glXDestroyContext == NULL) || |
503 (this->gl_data->glXMakeCurrent == NULL) || | 515 (this->gl_data->glXMakeCurrent == NULL) || |
525 | 537 |
526 handle = this->gl_config.dll_handle; | 538 handle = this->gl_config.dll_handle; |
527 if ( this->gl_data->glXGetProcAddress ) { | 539 if ( this->gl_data->glXGetProcAddress ) { |
528 return this->gl_data->glXGetProcAddress((const GLubyte *)proc); | 540 return this->gl_data->glXGetProcAddress((const GLubyte *)proc); |
529 } | 541 } |
530 return SDL_LoadFunction(handle, proc); | 542 return GL_LoadFunction(handle, proc); |
531 } | 543 } |
532 | 544 |
533 #endif /* SDL_VIDEO_OPENGL_GLX */ | 545 #endif /* SDL_VIDEO_OPENGL_GLX */ |