0004-darwin-use-glx-instead-of-opengl-framework.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From d010922282580a32dfebcda12ee1c307b3ef6005 Mon Sep 17 00:00:00 2001
  2. From: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
  3. Date: Mon, 18 Jan 2016 09:49:55 -0800
  4. Subject: [PATCH 4/4] darwin: Use GLX instead of OpenGL.framework if it is the
  5. current context
  6. Also makes a stab at similar support for Win32
  7. anholt/libepoxy#63
  8. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
  9. Fetched from pull #81 on github for libepoxy:
  10. https://github.com/anholt/libepoxy/pull/81/commits
  11. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  12. ---
  13. src/dispatch_common.c | 29 ++++++++++++++++-------------
  14. 1 file changed, 16 insertions(+), 13 deletions(-)
  15. diff --git a/src/dispatch_common.c b/src/dispatch_common.c
  16. index 163d348..cb9f76a 100644
  17. --- a/src/dispatch_common.c
  18. +++ b/src/dispatch_common.c
  19. @@ -482,16 +482,20 @@ epoxy_glx_dlsym(const char *name)
  20. void *
  21. epoxy_gl_dlsym(const char *name)
  22. {
  23. -#ifdef _WIN32
  24. +#if defined(_WIN32) || defined(__APPLE__)
  25. +if (!epoxy_current_context_is_glx()) {
  26. +# if defined(_WIN32)
  27. return do_dlsym(&api.gl_handle, "OPENGL32", name, true);
  28. -#elif defined(__APPLE__)
  29. +# elif defined(__APPLE__)
  30. return do_dlsym(&api.gl_handle,
  31. "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL",
  32. name, true);
  33. -#else
  34. +# endif
  35. +}
  36. +#endif
  37. +
  38. /* There's no library for desktop GL support independent of GLX. */
  39. return epoxy_glx_dlsym(name);
  40. -#endif
  41. }
  42. void *
  43. @@ -615,7 +619,7 @@ epoxy_get_bootstrap_proc_address(const char *name)
  44. */
  45. #if PLATFORM_HAS_GLX
  46. if (api.glx_handle && glXGetCurrentContext())
  47. - return epoxy_gl_dlsym(name);
  48. + return epoxy_glx_dlsym(name);
  49. #endif
  50. /* If epoxy hasn't loaded any API-specific library yet, try to
  51. @@ -644,22 +648,17 @@ epoxy_get_bootstrap_proc_address(const char *name)
  52. }
  53. #endif /* PLATFORM_HAS_EGL */
  54. - /* Fall back to GLX */
  55. + /* Fall back to the platform default */
  56. return epoxy_gl_dlsym(name);
  57. }
  58. void *
  59. epoxy_get_proc_address(const char *name)
  60. {
  61. -#ifdef _WIN32
  62. - return wglGetProcAddress(name);
  63. -#elif defined(__APPLE__)
  64. - return epoxy_gl_dlsym(name);
  65. -#else
  66. #if PLATFORM_HAS_GLX
  67. if (epoxy_current_context_is_glx()) {
  68. return glXGetProcAddressARB((const GLubyte *)name);
  69. - } else
  70. + }
  71. #endif /* PLATFORM_HAS_GLX */
  72. #if PLATFORM_HAS_EGL
  73. {
  74. @@ -674,8 +673,12 @@ epoxy_get_proc_address(const char *name)
  75. }
  76. }
  77. #endif /* PLATFORM_HAS_EGL */
  78. +#if defined(_WIN32)
  79. + return wglGetProcAddress(name);
  80. +#elif defined(__APPLE__)
  81. + return epoxy_gl_dlsym(name);
  82. +#endif
  83. errx(1, "Couldn't find current GLX or EGL context.\n");
  84. -#endif /* _WIN32 | __APPLE__*/
  85. }
  86. WRAPPER_VISIBILITY (void)