summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-09 02:45:56 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-09 02:45:56 +0000
commit7684ec15c2aa4f08465784468189e316fb0ec79d (patch)
tree7aadda06fe250e6a1bdd353087539ce967c65fb7 /third_party
parent4151d45b12283276609749e857724849100f753c (diff)
downloadchromium_src-7684ec15c2aa4f08465784468189e316fb0ec79d.zip
chromium_src-7684ec15c2aa4f08465784468189e316fb0ec79d.tar.gz
chromium_src-7684ec15c2aa4f08465784468189e316fb0ec79d.tar.bz2
linux: dynamically load libGL.so.1, and use glew to dynamically resolve symbols
This is to workaround NVIDIA's broken dlsym hook. BUG=16800 Review URL: http://codereview.chromium.org/525109 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/glew/include/GL/glxew.h85
-rw-r--r--third_party/glew/src/glew.c64
2 files changed, 126 insertions, 23 deletions
diff --git a/third_party/glew/include/GL/glxew.h b/third_party/glew/include/GL/glxew.h
index a29030d..ef89998 100644
--- a/third_party/glew/include/GL/glxew.h
+++ b/third_party/glew/include/GL/glxew.h
@@ -140,23 +140,41 @@ typedef struct __GLXcontextRec *GLXContext;
typedef unsigned int GLXVideoDeviceNV;
-extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase);
-extern Bool glXQueryVersion (Display *dpy, int *major, int *minor);
-extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value);
-extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList);
-extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap);
-extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix);
-extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
-extern void glXDestroyContext (Display *dpy, GLXContext ctx);
-extern Bool glXIsDirect (Display *dpy, GLXContext ctx);
-extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask);
-extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx);
-extern GLXContext glXGetCurrentContext (void);
-extern GLXDrawable glXGetCurrentDrawable (void);
-extern void glXWaitGL (void);
-extern void glXWaitX (void);
-extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable);
-extern void glXUseXFont (Font font, int first, int count, int listBase);
+typedef Bool ( * PFNGLXQUERYEXTENSIONPROC) (Display *dpy, int *errorBase, int *eventBase);
+typedef Bool ( * PFNGLXQUERYVERSIONPROC) (Display *dpy, int *major, int *minor);
+typedef int ( * PFNGLXGETCONFIGPROC) (Display *dpy, XVisualInfo *vis, int attrib, int *value);
+typedef XVisualInfo* ( * PFNGLXCHOOSEVISUALPROC) (Display *dpy, int screen, int *attribList);
+typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPPROC) (Display *dpy, XVisualInfo *vis, Pixmap pixmap);
+typedef void ( * PFNGLXDESTROYGLXPIXMAPPROC) (Display *dpy, GLXPixmap pix);
+typedef GLXContext ( * PFNGLXCREATECONTEXTPROC) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
+typedef void ( * PFNGLXDESTROYCONTEXTPROC) (Display *dpy, GLXContext ctx);
+typedef Bool ( * PFNGLXISDIRECTPROC) (Display *dpy, GLXContext ctx);
+typedef void ( * PFNGLXCOPYCONTEXTPROC) (Display *dpy, GLXContext src, GLXContext dst, GLulong mask);
+typedef Bool ( * PFNGLXMAKECURRENTPROC) (Display *dpy, GLXDrawable drawable, GLXContext ctx);
+typedef GLXContext ( * PFNGLXGETCURRENTCONTEXTPROC) (void);
+typedef GLXDrawable ( * PFNGLXGETCURRENTDRAWABLEPROC) (void);
+typedef void ( * PFNGLXWAITGLPROC) (void);
+typedef void ( * PFNGLXWAITXPROC) (void);
+typedef void ( * PFNGLXSWAPBUFFERSPROC) (Display *dpy, GLXDrawable drawable);
+typedef void ( * PFNGLXUSEXFONTPROC) (Font font, int first, int count, int listBase);
+
+#define glXQueryExtension GLXEW_GET_FUN(__glewXQueryExtension)
+#define glXQueryVersion GLXEW_GET_FUN(__glewXQueryVersion)
+#define glXGetConfig GLXEW_GET_FUN(__glewXGetConfig)
+#define glXChooseVisual GLXEW_GET_FUN(__glewXChooseVisual)
+#define glXCreateGLXPixmap GLXEW_GET_FUN(__glewXCreateGLXPixmap)
+#define glXDestroyGLXPixmap GLXEW_GET_FUN(__glewXDestroyGLXPixmap)
+#define glXCreateContext GLXEW_GET_FUN(__glewXCreateContext)
+#define glXDestroyContext GLXEW_GET_FUN(__glewXDestroyContext)
+#define glXIsDirect GLXEW_GET_FUN(__glewXIsDirect)
+#define glXCopyContext GLXEW_GET_FUN(__glewXCopyContext)
+#define glXMakeCurrent GLXEW_GET_FUN(__glewXMakeCurrent)
+#define glXGetCurrentContext GLXEW_GET_FUN(__glewXGetCurrentContext)
+#define glXGetCurrentDrawable GLXEW_GET_FUN(__glewXGetCurrentDrawable)
+#define glXWaitGL GLXEW_GET_FUN(__glewXWaitGL)
+#define glXWaitX GLXEW_GET_FUN(__glewXWaitX)
+#define glXSwapBuffers GLXEW_GET_FUN(__glewXSwapBuffers)
+#define glXUseXFont GLXEW_GET_FUN(__glewXUseXFont)
#define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0)
@@ -171,9 +189,13 @@ extern void glXUseXFont (Font font, int first, int count, int listBase);
#define GLX_VERSION 0x2
#define GLX_EXTENSIONS 0x3
-extern const char* glXQueryExtensionsString (Display *dpy, int screen);
-extern const char* glXGetClientString (Display *dpy, int name);
-extern const char* glXQueryServerString (Display *dpy, int screen, int name);
+typedef const char* (* PFNGLXQUERYEXTENSIONSSTRINGPROC) (Display *dpy, int screen);
+typedef const char* (* PFNGLXGETCLIENTSTRINGPROC) (Display *dpy, int name);
+typedef const char* (* PFNGLXQUERYSERVERSTRINGPROC) (Display *dpy, int screen, int name);
+
+#define glXQueryExtensionsString GLXEW_GET_FUN(__glewXQueryExtensionsString)
+#define glXGetClientString GLXEW_GET_FUN(__glewXGetClientString)
+#define glXQueryServerString GLXEW_GET_FUN(__glewXQueryServerString)
#define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1)
@@ -1186,6 +1208,28 @@ typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window,
#define GLXEW_EXPORT extern
#endif /* GLEW_MX */
+extern PFNGLXQUERYEXTENSIONPROC __glewXQueryExtension;
+extern PFNGLXQUERYVERSIONPROC __glewXQueryVersion;
+extern PFNGLXGETCONFIGPROC __glewXGetConfig;
+extern PFNGLXCHOOSEVISUALPROC __glewXChooseVisual;
+extern PFNGLXCREATEGLXPIXMAPPROC __glewXCreateGLXPixmap;
+extern PFNGLXDESTROYGLXPIXMAPPROC __glewXDestroyGLXPixmap;
+extern PFNGLXCREATECONTEXTPROC __glewXCreateContext;
+extern PFNGLXDESTROYCONTEXTPROC __glewXDestroyContext;
+extern PFNGLXISDIRECTPROC __glewXIsDirect;
+extern PFNGLXCOPYCONTEXTPROC __glewXCopyContext;
+extern PFNGLXMAKECURRENTPROC __glewXMakeCurrent;
+extern PFNGLXGETCURRENTCONTEXTPROC __glewXGetCurrentContext;
+extern PFNGLXGETCURRENTDRAWABLEPROC __glewXGetCurrentDrawable;
+extern PFNGLXWAITGLPROC __glewXWaitGL;
+extern PFNGLXWAITXPROC __glewXWaitX;
+extern PFNGLXSWAPBUFFERSPROC __glewXSwapBuffers;
+extern PFNGLXUSEXFONTPROC __glewXUseXFont;
+
+extern PFNGLXQUERYEXTENSIONSSTRINGPROC __glewXQueryExtensionsString;
+extern PFNGLXGETCLIENTSTRINGPROC __glewXGetClientString;
+extern PFNGLXQUERYSERVERSTRINGPROC __glewXQueryServerString;
+
extern PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay;
extern PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig;
@@ -1384,6 +1428,7 @@ extern GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name);
#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x)
#define GLXEW_GET_FUN(x) x
+extern GLenum glxewInit ();
extern GLboolean glxewIsSupported (const char* name);
#endif /* GLEW_MX */
diff --git a/third_party/glew/src/glew.c b/third_party/glew/src/glew.c
index fb67781..9dae16f 100644
--- a/third_party/glew/src/glew.c
+++ b/third_party/glew/src/glew.c
@@ -8865,6 +8865,28 @@ GLenum wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST)
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
+PFNGLXQUERYEXTENSIONPROC __glewXQueryExtension = NULL;
+PFNGLXQUERYVERSIONPROC __glewXQueryVersion = NULL;
+PFNGLXGETCONFIGPROC __glewXGetConfig = NULL;
+PFNGLXCHOOSEVISUALPROC __glewXChooseVisual = NULL;
+PFNGLXCREATEGLXPIXMAPPROC __glewXCreateGLXPixmap = NULL;
+PFNGLXDESTROYGLXPIXMAPPROC __glewXDestroyGLXPixmap = NULL;
+PFNGLXCREATECONTEXTPROC __glewXCreateContext = NULL;
+PFNGLXDESTROYCONTEXTPROC __glewXDestroyContext = NULL;
+PFNGLXISDIRECTPROC __glewXIsDirect = NULL;
+PFNGLXCOPYCONTEXTPROC __glewXCopyContext = NULL;
+PFNGLXMAKECURRENTPROC __glewXMakeCurrent = NULL;
+PFNGLXGETCURRENTCONTEXTPROC __glewXGetCurrentContext = NULL;
+PFNGLXGETCURRENTDRAWABLEPROC __glewXGetCurrentDrawable = NULL;
+PFNGLXWAITGLPROC __glewXWaitGL = NULL;
+PFNGLXWAITXPROC __glewXWaitX = NULL;
+PFNGLXSWAPBUFFERSPROC __glewXSwapBuffers = NULL;
+PFNGLXUSEXFONTPROC __glewXUseXFont = NULL;
+
+PFNGLXQUERYEXTENSIONSSTRINGPROC __glewXQueryExtensionsString = NULL;
+PFNGLXGETCLIENTSTRINGPROC __glewXGetClientString = NULL;
+PFNGLXQUERYSERVERSTRINGPROC __glewXQueryServerString = NULL;
+
PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay = NULL;
PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig = NULL;
@@ -9041,6 +9063,38 @@ GLboolean __GLXEW_SUN_video_resize = GL_FALSE;
#endif /* !GLEW_MX */
+#ifdef GLX_VERSION_1_1
+
+static GLboolean _glewInit_GLX_VERSION_1_1 (GLXEW_CONTEXT_ARG_DEF_INIT) {
+ GLboolean r = GL_FALSE;
+
+ r = ((glXQueryExtension = (PFNGLXQUERYEXTENSIONPROC)glewGetProcAddress((const GLubyte*)"glXQueryExtension")) == NULL) || r;
+ r = ((glXQueryVersion = (PFNGLXQUERYVERSIONPROC)glewGetProcAddress((const GLubyte*)"glXQueryVersion")) == NULL) || r;
+ r = ((glXGetConfig = (PFNGLXGETCONFIGPROC)glewGetProcAddress((const GLubyte*)"glXGetConfig")) == NULL) || r;
+ r = ((glXChooseVisual = (PFNGLXCHOOSEVISUALPROC)glewGetProcAddress((const GLubyte*)"glXChooseVisual")) == NULL) || r;
+ r = ((glXCreateGLXPixmap = (PFNGLXCREATEGLXPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPixmap")) == NULL) || r;
+ r = ((glXDestroyGLXPixmap = (PFNGLXDESTROYGLXPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXDestroyGLXPixmap")) == NULL) || r;
+ r = ((glXCreateContext = (PFNGLXCREATECONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXCreateContext")) == NULL) || r;
+ r = ((glXDestroyContext = (PFNGLXDESTROYCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXDestroyContext")) == NULL) || r;
+ r = ((glXIsDirect = (PFNGLXISDIRECTPROC)glewGetProcAddress((const GLubyte*)"glXIsDirect")) == NULL) || r;
+ r = ((glXCopyContext = (PFNGLXCOPYCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXCopyContext")) == NULL) || r;
+ r = ((glXMakeCurrent = (PFNGLXMAKECURRENTPROC)glewGetProcAddress((const GLubyte*)"glXMakeCurrent")) == NULL) || r;
+ r = ((glXGetCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentContext")) == NULL) || r;
+ r = ((glXGetCurrentDrawable = (PFNGLXGETCURRENTDRAWABLEPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentDrawable")) == NULL) || r;
+ r = ((glXWaitGL = (PFNGLXWAITGLPROC)glewGetProcAddress((const GLubyte*)"glXWaitGL")) == NULL) || r;
+ r = ((glXWaitX = (PFNGLXWAITXPROC)glewGetProcAddress((const GLubyte*)"glXWaitX")) == NULL) || r;
+ r = ((glXSwapBuffers = (PFNGLXSWAPBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glXSwapBuffers")) == NULL) || r;
+ r = ((glXUseXFont = (PFNGLXUSEXFONTPROC)glewGetProcAddress((const GLubyte*)"glXUseXFont")) == NULL) || r;
+
+ r = ((glXQueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)glewGetProcAddress((const GLubyte*)"glXQueryExtensionsString")) == NULL) || r;
+ r = ((glXGetClientString = (PFNGLXGETCLIENTSTRINGPROC)glewGetProcAddress((const GLubyte*)"glXGetClientString")) == NULL) || r;
+ r = ((glXQueryServerString = (PFNGLXQUERYSERVERSTRINGPROC)glewGetProcAddress((const GLubyte*)"glXQueryServerString")) == NULL) || r;
+
+ return r;
+}
+
+#endif
+
#ifdef GLX_VERSION_1_2
static GLboolean _glewInit_GLX_VERSION_1_2 (GLXEW_CONTEXT_ARG_DEF_INIT)
@@ -9546,7 +9600,13 @@ static GLboolean _glewInit_GLX_SUN_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT)
/* ------------------------------------------------------------------------ */
-typedef const char* ( * PFNGLXGETCLIENTSTRINGPROC) (Display *dpy, int name);
+#if !defined(GLEW_MX)
+GLenum glxewInit () {
+ if (_glewInit_GLX_VERSION_1_1(GLEW_CONTEXT_ARG_VAR_INIT)) return GLEW_ERROR_GLX_VERSION_11_ONLY;
+
+ return GLEW_OK;
+}
+#endif
GLboolean glxewGetExtension (const char* name)
{
@@ -9573,8 +9633,6 @@ GLboolean glxewGetExtension (const char* name)
return GL_FALSE;
}
-typedef Bool (* PFNGLXQUERYVERSIONPROC) (Display *dpy, int *major, int *minor);
-
GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)
{
int major, minor;