Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.72 KB | None | 0 0
  1. /*
  2.  * LD_PRELOAD shim which applies two patches necesary to get the game
  3.  * Divinity: Original Sin Enhanded Edition for Linux to work with Mesa (12+)
  4.  *
  5.  * Build with: gcc -s -O2 -shared -fPIC -o divos-hack.{so,c} -ldl
  6.  */
  7.  
  8. /* for RTLD_NEXT */
  9. #ifndef _GNU_SOURCE
  10. #define _GNU_SOURCE
  11. #endif
  12. #include <dlfcn.h>
  13. #include <GL/gl.h>
  14. #include <string.h>
  15.  
  16. #define _GLX_PUBLIC
  17.  
  18. /*
  19.  *   https://github.com/karolherbst/mesa/commit/aad2543bf6cfbd7df795d836e5ff4ec8686e4fdf
  20.  *     - allow env override of vendor string.  I actually just hard-coded
  21.  *       ATI Technologies, Inc., since that appears to be what's needed
  22.  */
  23. const GLubyte *GLAPIENTRY glGetString( GLenum name )
  24. {
  25.     static void *next = NULL;
  26.     static const char *vendor = "ATI Technologies, Inc.";
  27.     if(name == GL_VENDOR)
  28.     return (const GLubyte *)vendor;
  29.     if(!next)
  30.     next = dlsym(RTLD_NEXT, "glGetString");
  31.     return ((const GLubyte *GLAPIENTRY (*)(GLenum))next)(name);
  32. }
  33.  
  34. /*
  35.  *   https://gist.github.com/karolherbst/b279233f8b13c9db1f3e1e57c6ecfbd2
  36.  */
  37. _GLX_PUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
  38. {
  39.    static void *next = NULL;
  40.    if (strcmp((const char *) procName, "glNamedStringARB") == 0 ||
  41.        strcmp((const char *) procName, "glDeleteNamedStringARB") == 0 ||
  42.        strcmp((const char *) procName, "glCompileShaderIncludeARB") == 0 ||
  43.        strcmp((const char *) procName, "glIsNamedStringARB") == 0 ||
  44.        strcmp((const char *) procName, "glGetNamedStringARB") == 0 ||
  45.        strcmp((const char *) procName, "glGetNamedStringivARB") == 0)
  46.       return NULL;
  47.    if(!next)
  48.     next = dlsym(RTLD_NEXT, "glXGetProcAddressARB");
  49.     return ((_GLX_PUBLIC void (*(*)(const GLubyte *))(void))next)(procName);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement